|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
1 o/ d3 @/ R% K0 o- x; V其中有一段如下9 J5 n! Q' W, G0 K) F2 u: J( A
ask turtles with [ infected? = true ]
; {4 B. Z( h, A' f W我原本以为这句会回传『所有』infected? = true 的 turtle8 n' W( F- L' E, B( U3 G
但看结果似乎不是这样。
; B0 g# ]" @! q7 o9 \; @7 [" A
! d* u* F# N% _" o: A! T假设所有符合条件的有 5 笔+ I1 s7 S& n, T) L
有时候回传 1 笔,有时回传 3 笔,是不固定的
2 u! u. a! {2 O% W" V: m回头查语法定义
) g( @% p" R3 w) Bwith 9 V4 {0 ]0 d3 I. \7 ]; b! ]7 K
agentset with [reporter]3 L5 Q4 M- E* O4 ^4 @1 R' g/ U
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.7 l6 `" U' `1 O7 w# K, L( b
它只说回传 agents satisfying the given condition
# U% D4 c0 g( k P( R是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
) u- W* O5 N' h$ k8 u. k) N& V- p9 X! z0 X6 T3 t! i# S
想确定一下+ T3 I' @. j# r5 J. K( H! J
谢谢! d8 b( S9 z$ T" v
|
|