|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
1 j% F* ]. P, n" L- R) W# F4 d0 h其中有一段如下# I6 J" l3 T* j- q. y }! _
ask turtles with [ infected? = true ]
" Y! T5 D0 [' m% ?* ]我原本以为这句会回传『所有』infected? = true 的 turtle
& y2 ], g7 g7 V, I4 G但看结果似乎不是这样。4 D- J# N- I' A2 F' ]; m
+ B' Q4 u- N; R' k# y( h
假设所有符合条件的有 5 笔
# N- }, M: c0 a' P( s3 [有时候回传 1 笔,有时回传 3 笔,是不固定的
1 q0 d0 M# T- L3 X ?回头查语法定义+ y$ q+ f% u6 r1 V3 P6 n
with
8 i" \* K) b2 g1 q5 pagentset with [reporter] b" k7 @+ x+ m j C! @0 J
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.
/ ]/ @0 h( u/ b' D% N7 v( z它只说回传 agents satisfying the given condition
7 O8 L$ u" {) s9 R% ?/ c是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
1 e4 X- `3 x7 H- {9 e4 h7 a
2 e) R @$ X+ y! T& f想确定一下" M* y: o; L7 R4 W' K" }, ~& F' g
谢谢!
0 _. d: f, G1 M1 U4 {9 F6 } |
|