|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序* r: B& N/ [3 ?* s6 r4 k
其中有一段如下% `2 m6 K3 |2 Q) W8 V$ w8 [: M
ask turtles with [ infected? = true ]
; z% C+ s. Q, x! C3 o我原本以为这句会回传『所有』infected? = true 的 turtle
/ d8 W6 `! t% R4 F( E, G+ o! J但看结果似乎不是这样。
* U! r8 q Z; o! i) r1 {) \
" M; P) X* e7 V1 p# i5 i. V假设所有符合条件的有 5 笔
4 S3 ?% T7 o% Z6 [2 j有时候回传 1 笔,有时回传 3 笔,是不固定的
& J$ W* U, F- U' o# s9 e! _7 b! X' y回头查语法定义
1 l( \/ L7 w, J2 Z' d! C& P0 ywith 5 Y, V- q4 v( _& |" a7 G8 y- m
agentset with [reporter]
$ j: l* ^; `' T) yTakes 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.
( k: T" h* ^9 A' C- |它只说回传 agents satisfying the given condition
: u9 V+ S6 e2 u+ e9 c8 H是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? 7 y8 Z# |1 ]) I- b
$ ]' q0 U% G; v/ e4 `5 X
想确定一下
( n* C+ {4 ^; v$ Y3 Q2 m谢谢!
7 ?9 P( n5 G7 j* a" T( S) H |
|