|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
0 K- l& b+ {; z# Y; i其中有一段如下9 J6 ?) N. |6 T! _$ T
ask turtles with [ infected? = true ]
+ f, T `$ V/ v* ]* w/ Z我原本以为这句会回传『所有』infected? = true 的 turtle4 r- O/ Q; z- X: H1 x; e& P( d
但看结果似乎不是这样。
; j( p# M+ v4 I2 K" e$ f# L
% r0 {$ m: U1 L# F4 P" S( B* b假设所有符合条件的有 5 笔5 D: i4 A1 g& W4 Y6 c' Z
有时候回传 1 笔,有时回传 3 笔,是不固定的) C- s9 X$ s3 \
回头查语法定义
5 ]8 {& @# b# Z, Dwith
& [1 ?: ]4 B0 ^ f; Xagentset with [reporter]. l. L& g' d6 @& J
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.: X5 p- C) i+ o
它只说回传 agents satisfying the given condition% a5 d& ~ F& H0 j
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
! D4 m# y- g' ~, M1 A) R9 |2 o, T. Z: C) U9 }# }" I `
想确定一下
+ z6 S4 L+ V1 v8 i谢谢!
7 M( R) ?. x& [* M% r) e7 `2 c( s4 T |
|