如何让代理搜索它们尚未访问的区域NetLogo。

huangapple go评论115阅读模式
英文:

How to make agents search for patches they havent been to Netlogo

问题

我想让一只鹰飞越这张地图。然而,鹰只是在地图的边缘飞翔。边缘指的是任何不是黑色的部分。

我尝试了以下代码:

ask patches [ ifelse pcolor != 0 and pxcor > 350 or pxcor < 100 [set edge 1][set edge 0 ]]

ask Buteo-platypterus [face max-one-of patches with [edge = 1] [distance myself] fd 5] 

这使它们移动到边缘,但它们不会移动。我以为通过寻找最大值,它们会一直移动到最远的边缘,但事实并非如此。想法是鸟从一边到另一边,就像乒乓球一样,当它们到达最高点时,它们会下降,反之亦然。

这些鸟从地图的随机点开始,所以它们首先到达地图的任何一边,然后执行乒乓操作。

如何让代理搜索它们尚未访问的区域NetLogo。

已编辑以修复格式

如何让代理搜索它们尚未访问的区域NetLogo。

英文:

I want to make and eagle fly through this map. However, the eagle just flies by the edges of the map. The edge is anything that's not black.

I tried

ask patches [ ifelse pcolor != 0 and pxcor &gt; 350 or pxcor &lt; 100 [set edge 1][set edge 0 ]]

ask Buteo-platypterus [face max-one-of patches with [edge = 1] [distance myself] fd 5] 

This makes them go to the edge, but they don't move. I thought that by asking for the max it would always move to the furthest edge, but it didnt. The idea is that the bird goes from edge to edge, say like a ping pong, where as soon as they reach the topmost point they go down and vice-versa.

The birds start at a random point on the map, so the most first reach the edge of the map, any edge, and then do the ping pong thing.

如何让代理搜索它们尚未访问的区域NetLogo。

Edited to fix formating

如何让代理搜索它们尚未访问的区域NetLogo。

答案1

得分: 1

在我正在开发的模型中,我使用一个名为"turtles-own"的代理集来记住它们已经访问过的所有斑块。在每次移动之前,它们会将它们当前所在的斑块添加到列表中,然后寻找它们还没有访问过的最近的斑块。

请注意,如果有大量的乌龟和大量的斑块,这可能会相当慢,但这里重要的是概念。

英文:

In a model I am myself working on, I use a turtles-own agentset to remember all the patches they have already visited. Before each move, they add the current patch they are on, and then look for the nearest patch that they haven't visited yet.

turtles-own [patch-memory]

to setup
    ask turtles [set patch-memory [] ] ;Only do this to initiate the list, or when you intentionally want to forget everything that was in here
end

to go
    ask turtles [
       set patch-memory lput patch-here patch-memory
       move-to min-one-of patches with [ not member? self [patch-memory] of myself] [distance myself]
    ]
end

Edit: Do note that this can be quite slow if you have a lot of turtles and a lot of patches, but it is the concept that counts here.

huangapple
  • 本文由 发表于 2023年3月10日 00:53:18
  • 转载请务必保留本文链接:https://go.coder-hub.com/75687684.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定