Place a vehicle that looks identical to another vehicle in different locations

In my current project I am placing drivable vehicles all around my city streets.

The question is how can I easily place the same type of vehicle say in four different places without to much coding.

Currently I use it like this:

Car Type 1 is a vehicle in First Street.

Now I want to place that same vehicle say in Second Street and Third Street and Fourth Street.

Is it also possible that these vehicles can be spawn to these locations when they are no longer there.

Hope my question make sense.

2 Likes

I’m sure you are intending a more complicated implementation, but the basics are:

Or if you just want cars always available:

3 Likes

Here’s a version which populates your city with cars from a separate “Carpool” room. The cars are of different types and have different colours, which can be used to disambiguate between them.

You have to take care that the number of colours is equal to or greater than the number of cars of a type (so that each car of that type can have a unique colour), and that the number of cars in the carpool is equal to or greater than the number of roads.

There are various ways one could do it, so this is just a suggestion.

Code:

A road is a kind of room.

First Street is a road.
Second Street is a road. It is east of First Street.
Third Street is a road. It is east of Second Street.
Fourth Street is a road. It is east of Third Street.

Colour is a kind of value. The colours are white, yellow, orange, red, blue, green, beige, brown, grey, black.

A car is a kind of vehicle. Understand "car" as a car.

A car has a colour. A car is usually black.
Before printing the name of a car: say "[colour] ".
Understand the colour property as describing a car.

A sedan is a kind of car. The description of a sedan is "It's a standard [colour] sedan."
A convertible is a kind of car. The description of a convertible is "It's a fun [colour] convertible."
A minivan is a kind of car. The description of a minivan is "It's a boring [colour] minivan."
A coupe is a kind of car. The description of a coupe is "It's a sleek [colour] coupe."

The Carpool is a room.

In the Carpool are five sedans, two convertibles, three minivans, two coupes.

To paint (name of kind of value K):
	let palette be the list of colours;
	sort palette in random order;
	repeat with paint-target running through Ks in the carpool:
		now the colour of paint-target is entry 1 of palette;
		remove entry 1 from palette;
	 
When play begins:
	paint sedans;
	paint convertibles;
	paint minivans;
	paint coupes;
	repeat with target-location running through roads:
		move a random car which is in the Carpool to the target-location;

Example output:

First Street
You can see a white minivan (empty) here.

>gonear carpool
Carpool
You can see a beige sedan (empty), an orange sedan (empty), a white convertible (empty), a brown convertible (empty), a green minivan (empty), a brown minivan (empty), a grey coupe (empty) and a yellow coupe (empty) here.

>x brown
Which do you mean, the brown convertible or the brown minivan?

>minivan
It’s a boring brown minivan.

>x coupe
Which do you mean, the grey coupe or the yellow coupe?

>grey
It’s a sleek grey coupe.

>gonear first
First Street
You can see a white minivan (empty) here.

>enter car
You get into the white minivan.

>e

Second Street (in the white minivan)
You can see a grey sedan (empty) here.

>e

Third Street (in the white minivan)
You can see a red sedan (empty) here.

>e

Fourth Street (in the white minivan)
You can see a green sedan (empty) here.

>enter sedan
(getting out of the white minivan)
You get into the green sedan.

2 Likes

Thanks, will try this but how can I put the same type of car. blue sedan, in two or three different locations like:

Blue sedan in First Street
Blue sedan in Second Street
Blue sedan in Third Street.

1 Like

Thanks, I try this and see how it can fit into my project.

2 Likes
A car is a kind of vehicle. Understand "car/automobile" as a car.
A sedan is a kind of car. Understand "sedan" as a sedan.

An old blue sedan is a sedan in First Street.
Bob's blue sedan is a sedan in Second Street.
3 Likes

Thanks for your suggestion and that might work in my project.

Can’t you in some way say:

An blue sedan is a sedan in First Street.
An blue sedan is a sedan in Second Street.

What I mean is a different car but a look alike in all aspects of the car, same color, same make and model, same looks and everything.

Will that possible in some way.

1 Like

Yeah, just make blue sedan a kind of car and you can place multiple identical ones. However, working with generic instances of a kind is often complicated in Inform, and it generally looks more generic to a player, so I think Hanon’s approach is almost always the better path.

5 Likes