|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
, w4 n0 F3 C( w p$ @其中有一段如下4 X7 K3 @1 W. D6 V9 R9 c
ask turtles with [ infected? = true ]
# Q/ p# ]; s, ^0 ]/ g* p- r+ V我原本以为这句会回传『所有』infected? = true 的 turtle1 n- h) V4 ^1 Z ?+ {$ C
但看结果似乎不是这样。( j# N6 D+ y2 \' y
9 Z8 C: o& ?( Q& G假设所有符合条件的有 5 笔7 u- v, }5 i, k2 c1 H" z8 U
有时候回传 1 笔,有时回传 3 笔,是不固定的. }3 R1 d; G4 u) g9 t
回头查语法定义
2 a2 C' Q. P6 L8 p$ Z& m4 _) D, \with + L. I: ~9 z; \; y5 I
agentset with [reporter]
0 v- I1 A# V0 T9 rTakes 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.
* B: e$ O+ n2 U9 K% A8 J它只说回传 agents satisfying the given condition
8 r# }, }# K- Z是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? 0 }8 |: `6 z- J# n, J+ ^, i
! z$ U8 o" _5 k1 P8 k
想确定一下9 f& _" a+ A0 q' c& x" V, F0 V$ C
谢谢!
- B% C* z+ O5 y4 x7 {8 z- K |
|