|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序8 m3 X6 {% m8 L a4 q
其中有一段如下! n: z8 E. x# B5 l6 O2 s& _$ d+ S
ask turtles with [ infected? = true ]
: @# R- @& ?) Z2 J1 e我原本以为这句会回传『所有』infected? = true 的 turtle! ?; `1 l& X; F' d% j6 \
但看结果似乎不是这样。3 t+ x+ u/ X% u+ @- X
4 N5 n6 T7 k( g7 l$ B& |' O: ?: h; M
假设所有符合条件的有 5 笔
5 y w2 ~5 W( i有时候回传 1 笔,有时回传 3 笔,是不固定的1 i, B# Q% K/ d8 B4 n+ G
回头查语法定义
3 ~$ ?- t5 i; m9 D `2 _( ~* K% bwith
1 i) n( M* R7 p$ b' wagentset with [reporter], c7 c; F3 j! v% w- ^; m7 T+ w* ~1 A
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.% X! B# o1 f$ x6 ]. j5 `& Q$ D
它只说回传 agents satisfying the given condition8 @5 l: G* H7 O' @
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? 0 e% j4 O4 {: @4 V7 `
: O2 E% o* N& i. Y( v' X- D/ W, D2 ~想确定一下) y. b! w8 A! z" G: y5 l$ O; F3 ^
谢谢! _. m; A5 M$ o- A
|
|