|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
/ k% O! |, s0 A; K/ N. }' ]. t' L其中有一段如下1 y4 Z' B% ?/ |9 p1 ]
ask turtles with [ infected? = true ]
* N4 ?$ F3 p/ Y1 H+ {# X9 h我原本以为这句会回传『所有』infected? = true 的 turtle5 ~) r; V1 ~3 O
但看结果似乎不是这样。
0 M6 i4 P2 l. a8 G
$ z) S7 a7 Q' `3 c% u假设所有符合条件的有 5 笔* F/ b4 l, V* _
有时候回传 1 笔,有时回传 3 笔,是不固定的# P* v" L9 l7 P! ?1 d% n$ F
回头查语法定义) s E0 u5 Y" x
with
0 w0 z- j* G1 \5 v2 ?$ Dagentset with [reporter]
8 |5 Y$ p; O9 E: k J; z: BTakes 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.1 x2 i# [4 [3 n4 Y
它只说回传 agents satisfying the given condition% L0 z6 e d/ R6 }* ]
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
! F$ t2 l) E7 ~4 ~5 d$ F+ u1 ?" P- R! ]% H1 f8 S% H! m
想确定一下
0 R( i4 r+ L% V: R b! v谢谢!- F n+ r# E) Y0 m& P9 F
|
|