|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序$ Y/ n( L) Q; l$ ~" c8 W) |
其中有一段如下6 \+ X) j( D6 e" s; k
ask turtles with [ infected? = true ]
6 c, h9 U7 H- X3 X4 z0 T我原本以为这句会回传『所有』infected? = true 的 turtle; ~/ W' X8 J+ `8 \6 g
但看结果似乎不是这样。 V% d- O* o% @
3 Q/ b+ E4 N: p; j2 @7 r假设所有符合条件的有 5 笔
) j- g* X1 B& c- u, t5 l, R5 S有时候回传 1 笔,有时回传 3 笔,是不固定的
! m# _3 R/ H+ a1 O% T回头查语法定义" o" }0 F* q, J5 C5 ?
with
/ S3 a9 ~% K5 k0 r3 Dagentset with [reporter]3 ]2 R" d/ E9 T& o f9 ]
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.# [6 u$ c4 h4 {0 a9 H
它只说回传 agents satisfying the given condition& ~- t3 z/ s; d: S" Y: C( M% h
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
2 q I9 O5 L: ~. z# Z
/ @5 h6 n2 l4 _: L- n) w想确定一下
: n. O$ ?+ g3 f4 {0 ?谢谢!
- H& R$ v% {/ R& ?! M0 X |
|