|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
! l- T. D0 U* K5 E, |5 @$ l( f9 g* s其中有一段如下$ O( L9 M: D5 I4 \7 e4 E
ask turtles with [ infected? = true ]
+ q9 Q0 X0 p/ O. W/ t我原本以为这句会回传『所有』infected? = true 的 turtle* n: {: O# H# H9 r+ K
但看结果似乎不是这样。
7 f" [# l/ k0 R% c$ N" M6 }2 d5 y# S
假设所有符合条件的有 5 笔
" l0 Q! u" }2 D( D. R2 R有时候回传 1 笔,有时回传 3 笔,是不固定的! P7 }9 e% q- Z+ X
回头查语法定义
+ Z) T7 E8 U& s8 j1 Fwith
& q# S2 u9 _2 \7 Ragentset with [reporter]
; R4 v$ E, J% E9 A5 X3 C lTakes 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.- K2 q0 ]+ o& t5 i8 U I
它只说回传 agents satisfying the given condition- B: Q* {9 R9 D. j7 Z0 U# Z
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? ) E; J$ b3 P6 T
8 w: T5 @& { ^, i1 ]7 q
想确定一下
5 h# y, n5 R! H2 k0 r/ N' A谢谢!7 V$ _- }' G: i# W$ q0 T7 |
|
|