|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序0 o* M0 P+ J! `- L$ {4 n5 v' `8 W
其中有一段如下' M% {, U6 `. k0 a# P
ask turtles with [ infected? = true ]
: ^2 V4 d( f+ g8 `' {/ [7 {" f/ t, u我原本以为这句会回传『所有』infected? = true 的 turtle4 s8 e+ W" [! x9 t8 t( Q- x3 n
但看结果似乎不是这样。% k+ M) }6 X- T1 N( g( ~) Q/ G
) ~2 Y0 K* t. O4 v1 l假设所有符合条件的有 5 笔3 Q Z2 s! w: D4 M( X5 K
有时候回传 1 笔,有时回传 3 笔,是不固定的
( A& X9 k& y! ]0 n* b) {$ D回头查语法定义2 i x# j4 B2 I4 |$ L- w% w
with , M6 B( H$ j9 _( H
agentset with [reporter]
l( l$ p/ s7 Q4 b% T: WTakes 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.- o8 H8 f9 @ T* Z9 i7 q7 }
它只说回传 agents satisfying the given condition
! {! \) p3 `% ^! E是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? + T* L- G& a9 Z |0 z+ v+ B) R
8 u7 K% |# F* u: S
想确定一下
l( f N9 d4 \/ b谢谢!
3 K/ G& Z+ R4 B z/ D2 Y+ E/ ^ |
|