|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
/ }! {& f7 w2 x4 ~' J其中有一段如下1 g$ n. S" S3 w0 s
ask turtles with [ infected? = true ] % K! R* J% S! j9 o& k* a0 l
我原本以为这句会回传『所有』infected? = true 的 turtle- I S( n/ Q& h8 o1 K' \
但看结果似乎不是这样。
: q5 r1 k6 K/ F! G( W) H/ V: F( \% F$ y1 D6 {$ |, ^
假设所有符合条件的有 5 笔4 ?2 t+ b1 F, S+ V
有时候回传 1 笔,有时回传 3 笔,是不固定的
1 \, v; C7 Z& q4 H5 M回头查语法定义2 |+ T# @$ ~9 g ]
with
2 b& @* [/ H" L4 _3 C; d/ y, Uagentset with [reporter]4 H/ N- W: j3 q, ~4 W# K9 ?
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.
" v" y: e4 x8 H( P/ |# c2 j1 l它只说回传 agents satisfying the given condition4 \$ [/ Y7 h z d5 T
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
" [4 P+ ?+ @; V# p4 t0 X; v" ]* S; y1 ^5 ?; s# h
想确定一下
% G' p7 [, E5 k6 X/ O. g; I谢谢!
1 W, B9 |; z* {% I |
|