|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
. s& D ~1 C( b8 V0 N& ?其中有一段如下/ t7 C- `3 i" j' G( ~& t o3 O
ask turtles with [ infected? = true ]
$ [2 f8 k1 {' V. `9 ^. y, O( ]9 @% K我原本以为这句会回传『所有』infected? = true 的 turtle- w2 |- N0 A# Z( @
但看结果似乎不是这样。, G" L6 [, d( i* h; ?8 q
2 i! c5 _# ]: q# H/ E2 l
假设所有符合条件的有 5 笔
! Z4 V1 s! f! a" d/ q. R6 l& s有时候回传 1 笔,有时回传 3 笔,是不固定的
/ F/ H y8 ^! j5 }: |回头查语法定义
9 {' k+ G& M( {7 @, j1 }with
0 w* Q# b# o9 T3 F k# e. Cagentset with [reporter]
0 ]; _! r/ U0 Z( ~+ E) f% QTakes 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.
8 N8 d" X' I/ v它只说回传 agents satisfying the given condition8 h! K6 H9 q0 |# D# G
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? ' Y5 _4 |& W3 o9 N+ I# Y! `
7 w+ U% Y! ?) { v! _" w想确定一下6 N4 s+ E) {4 A2 l$ q Q9 ~& Y
谢谢!1 U$ g0 E1 X: r8 r3 Z' _8 r, \
|
|