Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/flash/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何计算netlogo中特定实例上一组补丁上的海龟数_Netlogo - Fatal编程技术网

如何计算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