|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
& A( Q# T* @7 {* `" ?: b* ~其中有一段如下; v- Z/ y7 y% _/ x
ask turtles with [ infected? = true ] 3 B7 S: _& J7 w/ E
我原本以为这句会回传『所有』infected? = true 的 turtle1 x4 H6 b$ n" B$ W" ^2 d
但看结果似乎不是这样。4 U" `' V! D& T! m
: ~$ q/ J7 k! ]! i+ n) b4 c
假设所有符合条件的有 5 笔' {2 q/ g/ p* K2 P
有时候回传 1 笔,有时回传 3 笔,是不固定的
# [( D& o7 m7 A. E% @* b回头查语法定义
) P# l" q) U! ?1 R. n" _3 `4 _' ^with . Y3 q( u! m) S. D8 T4 i, v! L
agentset with [reporter]9 S1 S' Q/ [" l$ a8 m6 Z
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.7 R1 F2 A2 y0 U3 L- k! l0 w- S' {; Y
它只说回传 agents satisfying the given condition% `$ O: R- ~! \0 r/ ~* g
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? ) E/ r T# ^, t# }
9 I) z3 T' h# g9 E7 Y" e; Q0 n, ~想确定一下- G) }, _; A1 P/ U
谢谢!
$ o4 m( W6 e$ K' I$ T" Z+ s# {) X/ r |
|