Mercurial
Mercurial

Reputation: 79

Major and minor Netlogo problems

what happens is the cars move throughout the simulation and so do the people in the image, the blue car at the moment is on coordinate (16,-2) and the people are on (20, -5) (20,-6) (20,-7) and (20, -8) respectively, what I want to do is make any car that is directly infront of a person to slow down and not hit the person, or go into the same patch.

So for example, if the car drives to patch (19, -2) and a person is on patch (20,-2) the car stops, like when you're pulling the brakes of your car and lets the person pass. I tried this

And this does not work, it just slows down every car, even cars that are behind the current car (there are multiple cars in the simulation), please how do i fix this? The in-cone should check what is ahead of the turtle but it seems not to be doing so.

And on the minor note, I have a global variable value which keeps tracks of the amount of times the car has collided with a person and that works fine, this is the code for it

How do I overcome this?

Upvotes: 0

Views: 61

Answers (1)

JenB
JenB

Reputation: 17678

Looks like a typo to me. You want the car to do the move-forward procedure when there's NOT any people in front, but you have any? instead of not any?.

More generally, do you know the car is actually facing the direction you think it is? When I am using in-cone, I often test the range of the command. For example, in your case, I might temporarily create people all over the world, open an inspect window for the car I care about (the blue one), then use the code box inside the inspect window to do something like ask people in-cone 1 180 [set color red]. That will show me the range of where the car will respond to someone being there.

Upvotes: 2

Related Questions