|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
8 I% p9 n5 m8 _. F x其中有一段如下
) w( ?: D- H! e5 H/ Wask turtles with [ infected? = true ] ' a" T3 | A) w* d4 ]
我原本以为这句会回传『所有』infected? = true 的 turtle
' Q; a( n7 E5 o$ y5 y7 q但看结果似乎不是这样。- s2 k5 X# `" N6 t6 f
) A1 Y, \5 C" |4 Q
假设所有符合条件的有 5 笔' c2 n0 ]8 h6 a5 N% t. [. U, t) F
有时候回传 1 笔,有时回传 3 笔,是不固定的! s0 b/ S, j; d' u; g- m
回头查语法定义
" \; Z! J6 }" o' x4 _$ y1 ~with 8 }+ |% G5 Q5 L# b; w7 w! p
agentset with [reporter]
$ H1 b+ C9 h8 y0 k* E6 W7 G& STakes 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.
! a$ T' ~2 u# W! n4 h: [. X; P它只说回传 agents satisfying the given condition
: `8 N0 X% E w/ t2 P8 \1 M9 Z是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
8 O" l0 j* N9 O$ v7 L# X& `# y+ B$ P4 K0 O
想确定一下
# R' I. O7 c5 v% _2 t谢谢!
4 u% V& C. y8 R* F |
|