|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
8 c& }) H5 n# I! `其中有一段如下6 C# d* N6 ~; v0 G
ask turtles with [ infected? = true ]
$ [; O b' X8 |6 M1 ]1 ]- n) G6 h. _" p G我原本以为这句会回传『所有』infected? = true 的 turtle3 T# S: l# m7 M' o9 J; F
但看结果似乎不是这样。
% V2 X# ]' J ~0 T" S4 O
- u. W& Z+ c3 l' K9 o$ f3 \假设所有符合条件的有 5 笔
/ ]$ I3 l4 f' }1 k2 m1 D2 U有时候回传 1 笔,有时回传 3 笔,是不固定的+ @ E; m0 n R" h8 s& A( A& y5 F
回头查语法定义" @: g2 n( w' q5 w; f; ^
with ( X: J% h8 r) k: U- g
agentset with [reporter]; t% E0 G+ @2 I- [; K, p1 J
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., h3 f2 r4 \. Y1 G/ @
它只说回传 agents satisfying the given condition( i; R+ c0 [0 ~. F% q' Q
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? 8 [) I' A/ E4 ~0 W
& k2 f9 p1 t! {( `- w" I2 ?想确定一下2 I( q7 {4 T! r; y3 C
谢谢!# l4 M, t% O0 E7 n' ]- S
|
|