|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序8 X% e- I8 r1 F
其中有一段如下* M$ E* R8 i+ x8 @
ask turtles with [ infected? = true ] 6 A, y ~8 c6 F6 O6 @" G: v
我原本以为这句会回传『所有』infected? = true 的 turtle
6 Y4 o. E2 O! k* D但看结果似乎不是这样。3 F' ?$ _% u1 U
$ x$ v$ O. @# t假设所有符合条件的有 5 笔4 y' C) ` n- C3 o5 e: g2 u
有时候回传 1 笔,有时回传 3 笔,是不固定的
( Y7 }; L% a8 q: m \/ U9 V G* ]7 K+ T回头查语法定义. F7 k$ y) m; c- o: e9 g0 y
with - F4 c! c, }3 z* P
agentset with [reporter]5 |8 n; x. p6 ]' n' |
Takes two inputs: on the left, an agentset (usually "turtles" or "patches"). On the right, a boolean reporter. Reports a new agentset containing only those agents that reported true -- in other words, the agents satisfying the given condition.
& r }7 }6 E" f' ^! D它只说回传 agents satisfying the given condition {5 k% @1 Z3 d) A
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? 4 H# N7 L/ H9 g( c
( Q) v7 q, W, o3 [4 b( ]" W9 O想确定一下
, ]9 T7 ?; K( C; t# A* W谢谢!$ S# O9 i3 N! s6 i2 V5 o! A1 ]
|
|