|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序4 J% W' d1 Y2 O* w, y+ P
其中有一段如下- B) w0 y# ^8 M9 O
ask turtles with [ infected? = true ] & O' |( ^# S* S$ b# Y
我原本以为这句会回传『所有』infected? = true 的 turtle i7 z' W. F m, C" j5 A- w
但看结果似乎不是这样。; j U8 z( A% w" B, G( g( e
& q+ W' U- u0 F! q# I5 C, Q假设所有符合条件的有 5 笔
# W! I& Z$ L( _ e \" R4 U& M有时候回传 1 笔,有时回传 3 笔,是不固定的- c- r: }9 I6 Y+ L4 \5 Q# o* o: F" ~
回头查语法定义( {; J* B& J& S0 `7 r
with
& z' M2 ^7 S; \2 B |1 sagentset with [reporter]) U2 y3 F- b$ h; p
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.1 l' _$ N/ E n/ \) b; U( p
它只说回传 agents satisfying the given condition& b# l6 c/ h. ]& O. { K- f1 c
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
! g* x6 [2 b5 ` G3 D$ ^5 ~1 H# v7 U9 Y- H: q
想确定一下% s" b4 R9 E, }# | ^1 |
谢谢!
, p; I9 U( X* e- S/ l% [ |
|