netlogo - 如何“追踪”乌龟?
问题描述
我想跟踪如下创建的海龟:
- 时间 0:海龟 1 创建一个新海龟 - 对象 - 使用孵化 -
- time > 0:创建的对象被添加到新海龟的列表中,海龟2;
- 时间 > 0:乌龟 2 想与一个新乌龟共享这个对象,乌龟 3。然后该对象被添加到乌龟 3 的列表中......
要跟踪的海龟是对象。我想过访问路径/链接或更改创建的海龟的颜色(例如,询问 this-object [ set color red ]),但我隐藏了海龟,所以它没有意义。您对我如何在网络中跟踪这只乌龟的路径有任何想法吗?(你可以想象一辆发生事故的汽车,但司机并没有停下来,继续行驶,它又发生了新的事故……我想追踪的不仅是事故,还有造成事故的汽车,如果可能的话。
我希望你能帮助我。谢谢
解决方案
You have now asked essentially the same question at least 10 times in slightly different ways. It's clear that none of the answers have answered your question, but it's also clear that you aren't understanding any of the answers. While I would normally ask you to post what you have tried so far, it's probably best to start from the beginning.
Here is a complete model that does what you want. I have put print
statements at key points so that you can see that it does what you want.
breed [people person]
people-own
[ my-objects
]
breed [objects object]
objects-own
[ my-people
]
to setup
clear-all
create-people 5
[ setxy random-xcor random-ycor
set color red
set my-objects []
]
ask one-of people
[ hatch-objects 1
[ set color blue
set my-people (list myself)
let child self
ask myself [ set my-objects (list child) ]
]
]
reset-ticks
end
to go
ask one-of objects [move-object]
tick
end
to move-object
let target one-of people
while [target = first my-people] [set target one-of people]
let this-object self
ask target
[ type self type " Objects old: " print my-objects
set my-objects fput this-object my-objects
type self type " Objects new: " print my-objects
]
type self type " Owners old: " print my-people
set my-people fput target my-people
move-to target
type self type " Owners new: " print my-people
end
If you want to make any progress on your code, you need to completely understand this model first. Don't just copy the relevant bits into your code and try to amend. Instead, make a new NetLogo model for this code and understand every line - what it does, how it works. Once you understand it, you can then use the concepts and approach in your own model.
推荐阅读
- django - 在 Heroku Server django 上安装 poppler
- xaml - Back To Basics: Xamarin Forms Binding
- c - 在 C 中使用 scanf 时代码不会编译或抛出错误,永远卡在构建中
- postgresql - error while running the comannd 'psql' Error: You must install at least one postgresql-client-
package - javascript - 将对象链接到 jquery 函数
- java - 将 JSON 映射到 POJO 时获取空值
- amazon-web-services - AWS S3: An error occurred (AccessDenied) when calling the GetObject operation: Access Denied
- javascript - How to have a node's name be different than its ID using Cytoscape.js?
- machine-learning - 哪种预训练模型最适合灾难分类
- coq - 从 ssreflect finset 中提取/使用成员资格证明