|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
3 ]3 G- F+ \ z t0 o其中有一段如下& Z+ ^0 R1 |6 v( M7 S# `
ask turtles with [ infected? = true ]
9 i! ?; z4 Z, Y- Q, k( O% Q我原本以为这句会回传『所有』infected? = true 的 turtle8 }0 ~! c$ k( k
但看结果似乎不是这样。
. d1 U) U' ^1 a/ ] ^3 n2 W+ [, D- ]; [7 t* L$ E
假设所有符合条件的有 5 笔
0 i9 `# a3 n! z# x2 M有时候回传 1 笔,有时回传 3 笔,是不固定的
/ C- t* A9 B# | H3 w' Z7 j7 C回头查语法定义
0 X- z( c* p4 v$ mwith : x N e1 E$ V! q7 T! b! B8 F6 r) |
agentset with [reporter]3 s8 V+ S0 d2 j1 p
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.' m! F' X1 e4 G# z1 k
它只说回传 agents satisfying the given condition
2 D* P) H% N E2 v4 y& ]是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
0 z+ e6 [9 J5 D/ q! u4 E8 R/ c/ `0 g$ F
, T) m; T3 p/ y" C) O想确定一下
; p2 x5 B" A8 { G( R! C/ X7 F谢谢!! y8 J# d, a, q# S5 _
|
|