|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序) M' I# V: O2 F# ?6 l C# j; j
其中有一段如下9 B7 M4 ?6 l& L) k6 B
ask turtles with [ infected? = true ] ; z0 r: h, J. n: ]; q
我原本以为这句会回传『所有』infected? = true 的 turtle; \- l! D8 w; I; r$ C: W0 G
但看结果似乎不是这样。
8 r7 G: B- E3 s R1 B
# `6 d2 g4 w7 R9 Y/ {假设所有符合条件的有 5 笔3 e& Y. Y+ g1 c/ \+ W
有时候回传 1 笔,有时回传 3 笔,是不固定的0 v6 e3 K h' z6 U b) X6 _$ d: x
回头查语法定义1 Y7 M/ @3 a" J# _ {: x B
with
$ P) `" [* R+ p0 Z+ fagentset with [reporter]2 W" g# q! ?' _8 ?6 T* 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.
# ^$ o; ], b3 T# I" k它只说回传 agents satisfying the given condition/ m! L; p# t% D% [- x
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? $ v+ u3 _$ n* h5 ~* X
% \, K1 M2 `8 k0 d! L( P想确定一下
; r/ _$ l0 e2 ~# P$ {5 p5 K谢谢!7 Q, S! a% k, E9 v7 e4 d1 p7 {
|
|