|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序4 e* { z6 N. ~( N" l2 \- N
其中有一段如下! ^) J# G* F% t0 m+ E$ q5 N! g1 J/ G
ask turtles with [ infected? = true ] : J! A/ d, G$ V- T& Q0 y2 d- I4 J
我原本以为这句会回传『所有』infected? = true 的 turtle
& ?# }) P+ b6 E# f. X但看结果似乎不是这样。
$ ^4 ~; t c- _) ^7 L! c3 R
5 w& g+ H6 N6 J假设所有符合条件的有 5 笔5 H; \1 X- f) u4 y# t
有时候回传 1 笔,有时回传 3 笔,是不固定的8 D8 a/ a$ s) ?1 w: C. m
回头查语法定义
; I# q! z7 z0 u& l& E8 z) |" ywith
1 D2 p' m) ^+ r: k" `* {& B# J6 qagentset with [reporter]
, a" g8 H1 R; q! z9 n7 J) T. cTakes 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.- ~- q1 V6 V, w8 }# m {% ?
它只说回传 agents satisfying the given condition
& ^5 h* N3 Z, g+ A是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
5 `! m' ]% j2 ~% ?; T4 d6 J' f2 s$ |( J! [4 Y5 n
想确定一下
}0 A' L# C) S谢谢!& z! l! i7 u- W |. R
|
|