|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
- j" P! w [3 }& }+ K其中有一段如下" R4 ?5 }+ v6 y0 N
ask turtles with [ infected? = true ] - a2 R8 z, ]. N1 b
我原本以为这句会回传『所有』infected? = true 的 turtle
3 P& t* B# W3 Q. A( D但看结果似乎不是这样。
; a M* i) K+ Q4 A7 p7 A0 u' A
0 O/ o: |6 q. ]% v2 [, R2 U假设所有符合条件的有 5 笔
) Y9 z9 \5 k, W' R0 [ w* y有时候回传 1 笔,有时回传 3 笔,是不固定的
; |* R% T$ j) U. r! N3 i+ V" ^8 Z3 |回头查语法定义6 _ d; K7 z$ U& f4 J. I
with 3 j# e) F- y/ L9 C) h* Z0 y+ {$ E1 |
agentset with [reporter]% z7 h( h) f4 x- {/ U) x
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.* A1 x% d8 m5 p8 V5 n8 _# h
它只说回传 agents satisfying the given condition
1 C. w/ F7 h4 l7 V2 J. Q是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
4 ]# S' T, A$ W" x: E, ^, O/ I. x( n c& s# e" {. g5 B
想确定一下+ u' T$ O0 n7 [) d
谢谢!
' i9 A8 s2 R% ]$ K0 j: H+ _6 K |
|