【发布时间】:2020-05-14 22:20:48
【问题描述】:
我正在尝试在 Netlogo 中编写代码,让海龟等待一定时间(例如:2 秒),如果他的邻居小于一定距离。当他和他的邻居之间的距离超过那个距离后,这只乌龟就可以开始移动了。这是我的代码:
我对海龟的初始设置:
;;send people back to where they come from
ask turtles [
move-to one-of road with [not any? other turtles in-radius 4]
]
让海龟移动:
to move
face best-way-to goal
ifelse patch-here != goal
[
ifelse how-close < 2
[wait 2 fd 1]
[fd 1]
]
[stop]
end
to-report keep-distance
set close-turtles other turtles-on (patch-set patch-here neighbors4)
ifelse any? close-turtles
[set how-close distance min-one-of close-turtles [distance myself]]
[set how-close 100] ;this means cannot find neighbours around this people
report how-close
end
但这并没有给我想要的东西。有人知道如何在 Netlogo 中实现这一点吗?任何帮助真的很感激。谢谢!
【问题讨论】:
标签: netlogo agent-based-modeling