当所有补丁都被着色时,要阻止海龟

时间:2016-11-07 14:43:50

标签: netlogo

当海龟在斑块中覆盖世界时,我希望海龟能够停留在最后一片上,这样我才能记录下它们的蜱虫数量。

如果可能的话,我希望在随机位置设置刻度线,但只能随意面向北,东,南或西。

到目前为止,这是我的代码:

globals [marked-patches angle nextangle]

to setup   ca   ask patches   [ set pcolor black ]   crt turtle_amount
[set color red
    set size 1
    setxy (random 20) (random 20)]    reset-ticks
end

to go   ask turtles [
    fd 1
    rt random trt_ang
    lt random trt_ang
    if pcolor = black [set pcolor yellow]   ]   
tick end

1 个答案:

答案 0 :(得分:1)

在go中,特别是在turtle命令中,您可以添加:

to go   
ask turtles [
     fd 1
     rt random trt_ang
     lt random trt_ang
         if pcolor = black [
           set pcolor yellow
           if count patches with [pcolor = black] = 0 [
               stop
           ]
    ]   
]   
             tick
     end