我们可以在一些特定时间实例上计算一组补丁或单个补丁上的海龟数量(比如在勾选中)。
set turtle-at-setpatches count turtle-on patches with [ (pxcor >= 9 and pxcor <= 13) and (pycor <= 9 and pycor >= 2)]
我使用此代码获取计数,但此计数默认基于ticks。我需要的是特定刻度(或实例)上的数字计数。提前谢谢。
答案 0 :(得分:2)
回答问题:
if (ticks = 10) [
set turtle-at-setpatches
count turtles-on patches with [
(pxcor >= 9 and pxcor <= 13) and (pycor <= 9 and pycor >= 2)
]
可能更好的答案:收集表格中每个刻度的数据。如,
extensions [table]
globals [setpatches turtles-on-setpatches]
to setup
;compute setpatches only once
set setpatches patches with [ (pxcor >= 9 and pxcor <= 13) and (pycor <= 9 and pycor >= 2)]
crt 500
set turtles-on-setpatches table:make
reset-ticks
end
to go
ask turtles [setxy random-xcor random-ycor]
table:put turtles-on-setpatches ticks (count turtles-on setpatches)
tick
end