|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序3 X6 U3 E* i8 `% G: K& C# |, r
其中有一段如下
7 a; h$ Y: f- a) L* W7 Mask turtles with [ infected? = true ]
. i- u0 R7 J' v我原本以为这句会回传『所有』infected? = true 的 turtle
! ^0 R7 Z& R' ?6 v9 o' b但看结果似乎不是这样。
) M$ P$ W0 y' U; D4 _$ T" `% f+ S! u1 Q, k+ F
假设所有符合条件的有 5 笔# r M, W- ~. ^. W/ K* s
有时候回传 1 笔,有时回传 3 笔,是不固定的
4 Y3 z$ @3 H q9 P# O2 [$ d回头查语法定义
# R5 `/ j' k4 w- Zwith , T, _# w6 G5 I) N# ?
agentset with [reporter]
9 o+ g0 v# ^2 y2 s8 v7 B& bTakes 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.
: t/ k% p+ Q0 [! {- l7 o8 C0 X3 W3 M它只说回传 agents satisfying the given condition
4 R0 a$ `; S- k. a0 x* ~. T是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? 0 Q" ^* f y% G! _5 ]7 w U+ \/ O
+ @: j1 O6 ~3 H, {& y( Z& I
想确定一下/ O: S& W+ b5 x5 S
谢谢!
/ ]4 |1 L/ B2 Y/ t7 p( ?; i |
|