|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
& H+ r/ `: _& e其中有一段如下: T/ }3 Q7 m& w3 [& K3 C
ask turtles with [ infected? = true ]
) h/ \5 _ t/ Y$ a$ x. q# H6 w# y我原本以为这句会回传『所有』infected? = true 的 turtle
# i( l1 X" w7 k/ K1 G; y1 Q但看结果似乎不是这样。2 ]% l- J E3 D- K8 U
( R5 R- E7 G: T% D3 @1 \, {: W假设所有符合条件的有 5 笔( g. q( h% m2 j
有时候回传 1 笔,有时回传 3 笔,是不固定的
( b$ R& i7 k+ K% ^回头查语法定义: h5 D( v5 u: N- h$ h; z; X
with ) G! ?8 i8 }0 L2 ~. Y
agentset with [reporter]
% g% v3 V/ t# W6 B3 JTakes 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.) d+ L9 ]# R) j0 o6 N( {
它只说回传 agents satisfying the given condition
; v6 S m# S. }5 D( Y% \- _& |6 L F+ \是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? o( I* |% e7 ?' f7 M, ~: c7 e
7 |" L' \' F/ [3 Q' a9 Q
想确定一下+ g! T3 C! T1 b# w
谢谢!
2 b$ U6 v; s0 j1 l* |5 I$ s* S% v |
|