|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
1 @5 \, k {" s# J其中有一段如下7 `' z& d! u2 z
ask turtles with [ infected? = true ] 7 K" F+ b" W) i, `2 r
我原本以为这句会回传『所有』infected? = true 的 turtle
) L! v) B1 i$ V" V% Z* t. n' H# ^7 w但看结果似乎不是这样。4 @ v2 B, G; v4 V4 i
1 a1 P* B% Z: W+ y假设所有符合条件的有 5 笔8 W, ^% N' ^8 g4 S4 G( t9 ~ h
有时候回传 1 笔,有时回传 3 笔,是不固定的
9 |- k% w2 x7 |) J回头查语法定义
+ f T5 b: D: C) f! ]with
' w5 R0 B8 O7 q4 y' _agentset with [reporter]4 b$ X( v6 g* W9 G7 w
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.
% j: a$ W1 P6 a' M: G它只说回传 agents satisfying the given condition
1 `0 k9 b* E( u" W是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
# G7 z9 U8 L! F% h: Z
O- l3 s/ l. |' F% k1 L1 }) l: o' r; o想确定一下6 A# q* b8 e* ^2 u! n; N/ t6 @, q
谢谢!+ ~0 U5 G. \) ]9 S# X
|
|