修补程序集代码上的繁殖无法正常工作



招募过程的代码在模型的多次迭代中都运行良好,但最近第一只海龟似乎从食物中跳了出来,并将颜色变为橙色,这可能是寻找食物过程的一部分,而不是改变品种变白。如果乌龟进入食物贴片区域,它似乎工作顺利,但它们似乎接触到了食物贴片的边缘,并以某种方式触发了寻找食物的程序。或者,缩写为go的代码中的品种转换(询问领导者…设置品种觅食者,设置颜色橙色+1(可能正在发生,但这似乎不太可能。我尝试扩展补丁集,以包括似乎触发此更改的边缘补丁,但这不起作用。如有任何帮助解决此问题,我们将不胜感激。

to go
ask foragers
[wiggle
fd 1
look-for-food
recruit
reemerge]
ask leaders
[wiggle
fd 1
return-to-nest
if count followers with [color = violet] >= 2  ;; transform leader into forager that has found food
[set breed foragers
set color orange + 1]]
tick
end
to look-for-food  ;; forager procedure
if food > 0
[ set color orange + 1     ;; change color to indicate that they have picked up food
set food food - 1        ;; and reduce the food source
facexy nest-x nest-y
uphill-nest-scent
fd 1]
ask foragers with [color = yellow]
[if not any? followers and food-quality <= 0.6
[let choice random 3
(ifelse
choice = 0
[uphill-false-food-scent-a]
choice = 1
[uphill-food]
;;;;;;;;
[uphill-chemical])]]
if food-quality > 0.6 and color = yellow
[uphill-chemical
fd 3]
end
to recruit  ;; forager procedure
let potential-leaders foragers-on (patch-set patch -37 -17 patch -36 -17 patch -35 -17 patch -38 -18 patch -37 -18 patch -36 -18 patch -35 -18 patch -34 -18 patch -39 -19 patch -38 -19 patch -37 -19 patch -36 -19 patch -35 -19 patch -34 -19 patch -33 -19 patch -39 -20 patch -38 -20 patch -37 -20 patch -36 -20 patch -35 -20 patch -34 -20 patch -33 -20 patch -39 -21 patch -38 -21 patch -37 -21 patch -36 -21 patch -35 -21 patch -34 -21 patch -33 -21 patch -38 -22 patch -37 -22 patch -36 -22 patch -35 -22 patch -34 -22 patch -37 -23 patch -36 -23 patch -35 -23)
if any? potential-leaders and not any? leaders and food > 0 and count foragers <= 10  ;; checks if any leaders exist
[ ask one-of potential-leaders
[ set breed leaders
set color white]]  ;; transforms first forager to find food into the leader
end
```````

好吧,问题是海龟在两个不同的过程中移动,这两个过程都在同一时间内调用。想象一下,觅食者A会这样做(你代码的精简版(:

to go
ask foragers
[ wiggle
forward 1        ; moves 1
look-for-food
...
]
tick
end

因此,A以半随机的方向前进,然后调用寻找食物程序。进一步想象一下,他们的地盘上有食物:

to look-for-food
if food > 0
[ set color orange + 1
set food food - 1
facexy nest-x nest-y
uphill-nest-scent
forward 1                ; moves again if found food
]
...
if food-quality > 0.6 and color = yellow
[ uphill-chemical
forward 3                ; potentially moves again
]
end

因此,觅食者A在顶部通过条件,改变颜色,然后向巢穴移动。此外,如果满足其他条件,它将再移动3个距离。

最新更新