我的代码所做的是设置一个内部灰色补丁区域和一个外部黑色补丁区域,海龟可以在其中繁殖(每个补丁上有一个)。一旦乌龟到达灰色和黑色区域之间的边界,我就会分配可变能量,以将乌龟的繁殖延迟一定的刻度(每个刻度能量增长一个单位)。当能量达到一定数量时,我希望海龟在一个空的黑色斑块中孵化新海龟,但是在黑色区域中第一代新海龟之后,我收到运行时错误“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
None
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)