|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序% c* Z8 d- e' _- W- A
其中有一段如下+ A; `: M, P2 u8 u1 V" ?
ask turtles with [ infected? = true ]
& I* {5 z# V b# O% a2 V* }我原本以为这句会回传『所有』infected? = true 的 turtle
\9 e7 J$ G+ D8 h3 ?但看结果似乎不是这样。
/ Y- H- I0 i8 {6 u0 O8 W0 S7 V1 R0 p# S# \$ e( H4 {9 v
假设所有符合条件的有 5 笔! {1 O& }% _: I" v6 ?
有时候回传 1 笔,有时回传 3 笔,是不固定的( [, i) I* }- G' h9 y% u: _+ U
回头查语法定义
! `; t: k# d/ T* U$ Xwith
, d, E9 `( b& Q: M! R& @4 ]agentset with [reporter]
4 H/ }0 C' F3 j: v, NTakes 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.) O$ P# W9 k4 y. ~6 m
它只说回传 agents satisfying the given condition
; v. T. W8 f, a2 G3 h+ ~& _是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
3 A8 I; u8 O: N: K9 o5 G& R- u( q v2 z$ ^/ |: X6 c2 l
想确定一下; c* J( E& L- q9 c/ n! e
谢谢!
1 Y2 z0 S5 F( Q5 @- t8 o3 d( f |
|