|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序6 m% L; e" V5 H2 C) o, N' M
其中有一段如下2 @, D( L3 E; l# f7 k- A" A
ask turtles with [ infected? = true ]
. y4 k3 L) \$ F6 R$ n( I& }, Q我原本以为这句会回传『所有』infected? = true 的 turtle
% _, `2 i. }" ~但看结果似乎不是这样。
8 h. Z. W T& x+ S: S, X& E1 R" E% n9 T; K; J' [9 v k, \
假设所有符合条件的有 5 笔
; B0 x* I; W6 A$ m有时候回传 1 笔,有时回传 3 笔,是不固定的
1 b8 w- F! i1 s: x5 c8 @回头查语法定义
$ @8 t/ _$ F$ c/ N' f4 t: Swith
! z6 `- n8 y5 q1 T* f% fagentset with [reporter]
8 G0 v. J) Q! X7 FTakes 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.
[2 j& O! o5 u/ E它只说回传 agents satisfying the given condition! J* b# s: y: t# o
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? & S8 e- w" q, H# g. y* a1 C
6 \) J {" [- r, g4 N5 O4 x
想确定一下
; ~9 z& H; W% N$ \! M+ j& W, U谢谢!
[$ v+ b- N$ {2 h, E& W; @ |
|