我正在积极地尝试对交通2车道的样本模型进行重新编程,但是我自己添加了新的东西,我添加了看起来像一条人行道的底部,这就是问题所在。我添加的人似乎和汽车一起移动。我想要一种情况,当我开车时,我希望人们停下来,直到两分钟过去,然后人们才能越过另一侧,就像字面上的步行道。
这是控制汽车运动的代码,但是我不确定该怎么做,我在走车程序中尝试过。
ask turtles with [shape = "car"] [ move-forward ]
但是那没有用。这是完整的代码。
to go
create-or-remove-cars
ask turtles with [shape = "car"] [ move-forward ]
ask turtles with [ patience <= 0 ] [ choose-new-lane ]
ask turtles with [ ycor != target-lane ] [ move-to-target-lane ]
tick
end
to move-forward ; turtle procedure
set heading 90
speed-up-car ; we tentatively speed up, but might have to slow down
let blocking-cars other turtles in-cone (1 + speed) 180 with [ y-distance <= 1 ]
let blocking-car min-one-of blocking-cars [ distance myself ]
if blocking-car != nobody [
; match the speed of the car ahead of you and then slow
; down so you are driving a bit slower than that car.
set speed [ speed ] of blocking-car
slow-down-car
]
forward speed
end
[我知道它们会移动,因为人们也是乌龟,并且最初将乌龟编程为向前移动,但是我该如何只指定要移动的汽车而不是人们,并且如果可能的话,在一定时间后我该如何移动。
谢谢。
ask turtles with [shape = "car"] [ move-forward ]
您应该
ask cars [move-forward]
将确保分别处理cars
和people
。一旦有了品种,就永远不需要ask turtles
了,因为它将以相同的方式对待cars
和people
。 (cars
和people
都是乌龟。)
关于您关于时间的问题,您能否更具体些,也许在一个新问题中?查尔斯