|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序" V$ @5 E0 D+ ?
其中有一段如下+ I! T% z$ b5 j
ask turtles with [ infected? = true ] ^* m* d/ @0 U
我原本以为这句会回传『所有』infected? = true 的 turtle7 r5 o! @( m: J0 _
但看结果似乎不是这样。! s+ L* t" I/ i5 x1 F9 h
( D) X9 k2 l! [4 y# O& H, p假设所有符合条件的有 5 笔8 K( c+ r/ \+ q. l: c+ s. L: W
有时候回传 1 笔,有时回传 3 笔,是不固定的
8 c4 q2 g. y% j0 D+ R回头查语法定义/ y' r9 n" f- ^2 i( M, u% T% }
with
/ E' c* w6 B5 Z- p& e: P. |0 K4 F4 dagentset with [reporter]
; a- `* b( }' V/ @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.1 F, _" R+ }- |' d) z. f
它只说回传 agents satisfying the given condition& b: v0 O# S v% S6 b
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? 0 p( L1 d6 {2 A' D1 n; t) ]0 u* {
: M" l8 ^7 z4 Z
想确定一下4 b# e+ y6 w* y# t% o
谢谢!
6 W1 d; E; ]7 k3 t0 ] |
|