netlogo - 我怎么能让乌龟沿着路走去目的地
问题描述
最近我发现了帮助海龟沿着我指定颜色不是黑色的道路行走的代码。
let target one-of patches in-cone 1.5 180 with [pcolor != black]
if target != nobody
[
face target
move-to target
]
但我的问题是
当乌龟遇到死胡同时,它就停在那里不动了。
我的乌龟已经有了自己的目的地(这个模型是另一个)。如果我使用我之前提到的代码,也许它不起作用。那么我该如何解决这个问题呢?
这是我写的一些代码(另一个模型)。
ask turtles
[
set wlocation one-of patches with [pcolor = pink]
move-to wlocation
set myhome wlocation
]
之后,我会让海龟在模型中四处游荡。然后在某个特定的时间,海龟会通过下面的代码回到它的家。当乌龟到达它的家时,它会保持静止。
ifelse distance myhome > 2
[face myhome fd random 3]
[wander]
to wander
ifelse random 2 = 0 [rt random 30] [lt random 30]
end
有没有人有任何想法或建议?
解决方案
推荐阅读
- php - 如果 Woocommerce 产品价格为零,则显示联系按钮,否则显示添加到购物车按钮
- javascript - 单击工具提示后,辅助功能画外音开始从页面顶部阅读内容
- javascript - Jupyter Notebook:在循环中以编程方式运行 Notebook 单元
- docker - traefik 多端口端点路由
- service - DDD - 订阅者中的服务或处理程序?
- flutter - 颤振-我应该如何使用 package_info 处理应用程序版本?
- ios - 为什么字符串添加需要这么长时间才能构建?
- javascript - 如何完全清除输入字段?
- php - Laravel - 在 eloquent 的联合查询中访问 appends 属性
- python - 从超类调用子类的方法