|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序 c F9 M! O* {5 B" d
其中有一段如下( t9 Q& L) j, n
ask turtles with [ infected? = true ] ; l/ X* B5 z( J( {
我原本以为这句会回传『所有』infected? = true 的 turtle
- N r$ m+ U: G- r8 N) V7 q/ y4 y# c但看结果似乎不是这样。
; N; ~: @/ Q! R/ B( G& f* H
$ q: l* `$ v+ |; V假设所有符合条件的有 5 笔
9 Z+ L8 [9 ]! a' i$ H有时候回传 1 笔,有时回传 3 笔,是不固定的
; Z6 {, v2 i* A4 \2 Q6 |0 p回头查语法定义
; X, o# [' M( H5 I: A# ~! twith
! C9 t$ f4 ~5 Cagentset with [reporter]
7 z! P5 C& \# Q8 E ZTakes 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.
- ?+ J8 b6 p- S4 t' [/ b它只说回传 agents satisfying the given condition4 h$ ]' S: O. I6 [$ J3 ?! g' t k% S
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? / a9 i4 i4 @( ?3 d& @6 K
& r5 K; E5 b& H# q/ h: Y想确定一下
9 G! p/ j9 e9 V$ Z1 Q3 i! K. W! n" g4 X谢谢!
J' i$ ~5 K% F4 h4 Q1 `9 }: I6 m |
|