被要求去某些地区的海龟都聚集在一个地方
Turtles asked to go to certain areas are all congregating in one place
我正在编写一个捕食者-猎物模型,其中捕食者有一个小型内部机器学习模型来决定它将在哪个栖息地捕食。
如果捕食者在前一天没有成功狩猎,他们会随机分配四种策略中的一种。每个策略都有一个独特的栖息地,他们可以在其中狩猎,但是尽管他们都从环境的随机区域移动到一个中心位置,然后 "paint it" 关闭笔模式并忽略环境的所有其他部分,我无法弄清楚为什么。
我尝试了很多代码组合来解决这个问题,但它总是做同样的事情。我最近的尝试如下
if strat = "strat1" [ifelse any? patches in-cone 0 250 with [habitat = "rugged slope"]
[set target-patch min-one-of patches in-cone 0 250 with [habitat = "rugged slope"] [distance myself]
face target-patch
fd 1]
[face one-of patches with [habitat = "rugged slope"]
fd 1]]
if strat = "strat2" [ifelse any? patches in-cone 0 250 with [habitat = "gentle slope"]
[set target-patch min-one-of patches in-cone 0 250 with [habitat = "gentle slope"] [distance myself]
face target-patch
fd 1]
[face one-of patches with [habitat = "gentle slope"]
fd 1]]
if strat = "strat3" [ifelse any? patches in-cone 0 250 with [habitat = "rugged forest"]
[set target-patch min-one-of patches in-cone 0 250 with [habitat = "rugged forest"] [distance myself]
face target-patch
fd 1]
[face one-of patches with [habitat = "rugged forest"]
fd 1]]
if strat = "strat4" [ifelse any? patches in-cone 0 250 with [habitat = "gentle forest"]
[set target-patch min-one-of patches in-cone 0 250 with [habitat = "gentle forest"] [distance myself]
face target-patch
fd 1]
[face one-of patches with [habitat = "gentle forest"]
fd 1]]
]
end
如您所见,他们被告知要前往某些区域,但结果如下所示(附图片)
掠食者离开了他们的巢穴(粉红色),尽管他们对去哪里有独特的命令,但他们只是在中间相遇并画画。
我认为我们可能需要查看更多您的代码以了解区域的分布情况。但问题可能是 patches in-cone 0 250
只会查看捕食者当前所在的补丁(半径为零)。因此,如果(比如)strat = "strat2"
并且捕食者位于 habitat = "gentle slope"
的补丁上,目标补丁将是捕食者所在的补丁。如果栖息地不是 "gentle-slope",这可能是最有可能的,即使附近有一个特定的缓坡栖息地,它的路径也会很漫无目的。
我正在编写一个捕食者-猎物模型,其中捕食者有一个小型内部机器学习模型来决定它将在哪个栖息地捕食。
如果捕食者在前一天没有成功狩猎,他们会随机分配四种策略中的一种。每个策略都有一个独特的栖息地,他们可以在其中狩猎,但是尽管他们都从环境的随机区域移动到一个中心位置,然后 "paint it" 关闭笔模式并忽略环境的所有其他部分,我无法弄清楚为什么。
我尝试了很多代码组合来解决这个问题,但它总是做同样的事情。我最近的尝试如下
if strat = "strat1" [ifelse any? patches in-cone 0 250 with [habitat = "rugged slope"]
[set target-patch min-one-of patches in-cone 0 250 with [habitat = "rugged slope"] [distance myself]
face target-patch
fd 1]
[face one-of patches with [habitat = "rugged slope"]
fd 1]]
if strat = "strat2" [ifelse any? patches in-cone 0 250 with [habitat = "gentle slope"]
[set target-patch min-one-of patches in-cone 0 250 with [habitat = "gentle slope"] [distance myself]
face target-patch
fd 1]
[face one-of patches with [habitat = "gentle slope"]
fd 1]]
if strat = "strat3" [ifelse any? patches in-cone 0 250 with [habitat = "rugged forest"]
[set target-patch min-one-of patches in-cone 0 250 with [habitat = "rugged forest"] [distance myself]
face target-patch
fd 1]
[face one-of patches with [habitat = "rugged forest"]
fd 1]]
if strat = "strat4" [ifelse any? patches in-cone 0 250 with [habitat = "gentle forest"]
[set target-patch min-one-of patches in-cone 0 250 with [habitat = "gentle forest"] [distance myself]
face target-patch
fd 1]
[face one-of patches with [habitat = "gentle forest"]
fd 1]]
]
end
如您所见,他们被告知要前往某些区域,但结果如下所示(附图片)
掠食者离开了他们的巢穴(粉红色),尽管他们对去哪里有独特的命令,但他们只是在中间相遇并画画。
我认为我们可能需要查看更多您的代码以了解区域的分布情况。但问题可能是 patches in-cone 0 250
只会查看捕食者当前所在的补丁(半径为零)。因此,如果(比如)strat = "strat2"
并且捕食者位于 habitat = "gentle slope"
的补丁上,目标补丁将是捕食者所在的补丁。如果栖息地不是 "gentle-slope",这可能是最有可能的,即使附近有一个特定的缓坡栖息地,它的路径也会很漫无目的。