我的代码要做的是设置一个内部的灰色斑块区域和一个外部的黑色斑块区域,海龟可以在其中繁殖(每个斑块一个)。一旦海龟到达灰色和黑色区域之间的边界,我便分配了可变能量,以使海龟的繁殖延迟某些tick(每个(能量增长一个单位)。当能量达到一定数量时,我希望乌龟在一个空的黑色补丁中孵化新的乌龟,但是在黑色区域的第一代新乌龟出现后,我收到运行时错误“ MOVE-TO预期输入是代理,但得到了代替。”
这是我的代码
breed [greens a-green]
breed [reds a-red]
greens-own[energy]
to setup
clear-all
ask patch 0 0 [ ask patches in-radius 15 [set pcolor 3]]
ask n-of 20 patches with [pcolor = 3][sprout-greens 1 [set color green set energy 0]]
ask n-of 20 patches with [pcolor = 3][sprout-reds 1 [set color red]]
reset-ticks
end
to go
division
delay-expansion
expansion
tick
end
to division
ask greens[
let empty-space neighbors with [pcolor = 3 and not any? turtles-here] ;crea un set llamado "empty-space" que son los patches negros q rodean a la celula verde y q no estan ocupados
if any? empty-space [hatch 1 set color green move-to one-of empty-space] ; si existe algun patch negro alrededor, nace una celula verde y se ubica en ese patch
]
ask reds[
let empty-space neighbors with [pcolor = 3 and not any? turtles-here] ;crea un set llamado "empty-space" que son los patches negros q rodean a la celula roja y q no estan ocupados
if any? empty-space [hatch 1 set color red move-to one-of empty-space] ; si existe algun patch negro alrededor, nace una celula roja y se ubica en ese patch
]
end
to delay-expansion
ask greens[
let black-space neighbors with [pcolor = black and not any? turtles-here]
if any? black-space [set energy (energy + 1 )]
]
end
to expansion
ask greens[
let black-space neighbors with [pcolor = black and not any? turtles-here]
if energy > 5 [hatch 1 set color blue move-to one-of black-space]
]
end