|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
, g+ K) ?8 E/ W8 y0 C- z7 C其中有一段如下0 M" |4 J) k3 W8 |( V/ {+ G
ask turtles with [ infected? = true ]
0 l8 O) R+ W4 f, ~7 u8 D. T我原本以为这句会回传『所有』infected? = true 的 turtle9 I% ]- m. R2 q C( c
但看结果似乎不是这样。$ q( a2 H0 U5 h# l) y
4 |& I" ~6 i7 L6 c7 d7 B0 J假设所有符合条件的有 5 笔
6 t2 o7 L: O) v8 ]有时候回传 1 笔,有时回传 3 笔,是不固定的
" ]& Y0 j, ^9 \回头查语法定义
1 C/ r4 O1 O2 h- _+ c) Jwith 5 t7 T+ r# q& ^8 v/ p
agentset with [reporter]! p* P% C' Q% C- ^" p5 s
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., @1 E# f' o, e# i f: q
它只说回传 agents satisfying the given condition
, C3 T) A# ]+ F1 G( t! H+ F3 ?! j5 p是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? 6 ]; H0 h: b" ?4 R3 B) y
7 K& l3 A5 R' X" X
想确定一下, q+ b2 j _! ^: _3 s
谢谢!
% d* ~) H4 ^$ ~3 T |
|