|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
8 l' U* o# d7 C( `+ X其中有一段如下. a- F% u4 f- d+ \, [2 L$ C0 a* ]
ask turtles with [ infected? = true ]
2 f, D, {# p2 C" C, C3 l' s7 D我原本以为这句会回传『所有』infected? = true 的 turtle
4 B+ Q8 _9 j- y# g! X6 P! v/ O' u但看结果似乎不是这样。
8 Z [8 K. q6 R6 G
! i8 Z( S) `- C5 u假设所有符合条件的有 5 笔
4 H7 {$ W* ]9 l6 |有时候回传 1 笔,有时回传 3 笔,是不固定的* H- Y, Y* q% E; J/ ?
回头查语法定义 D9 g$ t" \1 H7 N: U1 ]
with + n5 s; n7 q2 Z* l2 Z8 V
agentset with [reporter]
/ D/ ]. ]6 v, \: e: Y+ I, QTakes 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.
- Y1 k8 y0 [4 w# i1 t |. r+ _它只说回传 agents satisfying the given condition4 Q+ m# G; N3 |- E8 C* \
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? - ?+ q Z% G- y. J
' ?4 U& \+ a, M想确定一下4 L: y4 \6 `/ ?: f6 f
谢谢!
+ O( X. K7 L& K W' F& ` |
|