如何计算netlogo中特定实例上一组补丁上的海龟数
在某个特定的时间,我们能数一数一组补丁或一个补丁上的海龟数量吗如何计算netlogo中特定实例上一组补丁上的海龟数,netlogo,Netlogo,在某个特定的时间,我们能数一数一组补丁或一个补丁上的海龟数量吗 将海龟设置为setpatches使用[(pxcor>=9和pxcor对问题的回答: if (ticks = 10) [ set turtle-at-setpatches count turtles-on patches with [ (pxcor >= 9 and pxcor <= 13) and (pycor <= 9 and pycor >= 2) ] if(刻度=10)[
将海龟设置为setpatches使用[(pxcor>=9和pxcor对问题的回答:
if (ticks = 10) [
set turtle-at-setpatches
count turtles-on patches with [
(pxcor >= 9 and pxcor <= 13) and (pycor <= 9 and pycor >= 2)
]
if(刻度=10)[
把海龟放在地上
用[
(pxcor>=9,pxcor=9,pxcor=9,pxcor谢谢你,先生,这意味着如果我们不取任何滴答值,那么默认情况下,它会为每个滴答计数给定补丁上的海龟总数。如果假设1滴答为1秒,那么我们可以说1秒内的计数为10(假设)。是这样吗?第一个版本只需将全局海龟设置为setpatches
一次,当ticks=10
时。之后,除非您在其他地方更改它,否则它不会更改。第二个版本引入一个表并创建一个记录:对于每个tick,表使用ticks
作为键,海龟计数作为值为您提供整个模拟过程的记录。您可以从表中获取任何时段的值。例如,table:get turtles on setpatches 10
将检索ticks=10
时记录的值。这里的表似乎有点过了头-为什么不使用l在列表的末尾添加一个数字把
?不管怎样,回答得很好。
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