|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
( _. R4 I+ c+ T7 F/ k' U其中有一段如下! C. x+ h) c6 U. j. t
ask turtles with [ infected? = true ]
- q" x1 F- R, S6 ?0 V# q2 u我原本以为这句会回传『所有』infected? = true 的 turtle
. J% n/ M3 a9 m但看结果似乎不是这样。
' c1 R v$ i2 h9 ?3 b
$ C0 a$ m* J a! @' ^+ F4 V. D. a2 N假设所有符合条件的有 5 笔0 W1 v+ R: V/ o( K- }0 [
有时候回传 1 笔,有时回传 3 笔,是不固定的
/ v' ^& j! d9 n5 k回头查语法定义
; Y7 ], r5 d( Z9 p) y7 P* k: Twith # n; ^( s* B( H. U |/ c
agentset with [reporter]/ E; q8 F* E, k8 C
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.
4 y- h4 c/ Z( f4 N# g( V它只说回传 agents satisfying the given condition
3 F6 u6 Y: W0 H是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
( x4 H9 B) u# @* Z" o
7 a" Z" C* P4 \; e想确定一下5 q$ [' r5 w4 M8 L
谢谢!, ^) l ^0 I% c. c1 T1 ^
|
|