|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序! C8 \1 @% y, V$ r. [) ]1 f" A
其中有一段如下
& v% t% N5 w# ~1 q) y) D0 k' Nask turtles with [ infected? = true ] 8 k: Y8 ^& K5 V, t9 J
我原本以为这句会回传『所有』infected? = true 的 turtle
( Q# I7 d) f3 r但看结果似乎不是这样。
9 j& F# N: w% K2 ^
& j9 \# C6 i* J3 T3 u s: f7 {9 Z假设所有符合条件的有 5 笔
( e4 a! e L: y: t, \0 u/ y有时候回传 1 笔,有时回传 3 笔,是不固定的' e% A" M6 H T
回头查语法定义
" x, L8 g5 O/ I! T0 p/ Ywith % L3 n! T2 Q4 _. }
agentset with [reporter]( u/ u o- w% G# v4 J. U5 u3 Q" @
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.! b5 h! l7 g3 ]: G$ e
它只说回传 agents satisfying the given condition
. n; a+ z& I+ z% ^- [ G是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? 8 x$ N. @; v9 ~6 h6 Q. t* a& \
& U/ F5 J$ J5 B6 r( S* h
想确定一下
! S0 q2 {! [% W g. Q- X% I. L谢谢!' _- X8 T- \, W' d1 W0 C
|
|