|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序$ }" Y0 X9 P! r8 A. L* F3 u
其中有一段如下& G; u+ v4 m8 i( ?
ask turtles with [ infected? = true ] 4 B9 m0 v! b- T, p
我原本以为这句会回传『所有』infected? = true 的 turtle$ h _0 u, k& n$ @; g( E' s
但看结果似乎不是这样。, N6 {+ F6 ^% a& Y0 O# A' I
* H/ W. e& P) R2 B6 k- d3 x7 Z+ H7 Q
假设所有符合条件的有 5 笔1 [0 o7 h& E( x$ n9 A: Z
有时候回传 1 笔,有时回传 3 笔,是不固定的
: Z! Z; t% l# E |# I: d" O回头查语法定义
: m! A# x4 w+ j7 ~6 gwith : N3 i. A7 D# i" \. D$ ^$ A& E; z
agentset with [reporter]4 J. P+ d0 W' {/ p
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.
' ?9 X, A8 F- t1 B! r% ^! j; E它只说回传 agents satisfying the given condition
8 S4 ^ \) l- P& c是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
" c5 h% v! r" V S
- ~4 Q4 \( B% J# S想确定一下& f8 k7 S% N. A- h/ R$ _7 e6 G
谢谢!# [& i- i8 L# v) W/ [( ]
|
|