|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
: a( z8 O' Q9 E# J1 u3 O其中有一段如下, P. g2 i/ Q# ^* Q- h1 j1 C7 i
ask turtles with [ infected? = true ]
6 W( v9 l- W# Y3 j' u" O我原本以为这句会回传『所有』infected? = true 的 turtle
8 ]5 y, I) a5 ?+ Z6 L1 K2 G9 L: f但看结果似乎不是这样。; \7 k% n: [# O* @) o) R$ W# T
( @4 W {5 r, N9 b" u& \假设所有符合条件的有 5 笔
[/ S* ?( ]3 F7 w( _$ G有时候回传 1 笔,有时回传 3 笔,是不固定的 x& P, B2 H T! Z
回头查语法定义
6 |7 X0 S- G* r) C5 D8 Swith ) V$ f {2 x/ y b: u
agentset with [reporter]
: ^. w; n- K; X4 uTakes 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.
C2 B1 x ^1 V3 A4 c1 t它只说回传 agents satisfying the given condition" X( N% |& v0 P; ?* b; B
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? " s+ z1 {. E2 l& I8 F
9 W% g/ ~# [6 z. V想确定一下* {( x/ D- g! J3 ~
谢谢!
& Z: ?. d4 g: p/ J- ?; @( w6 c. X6 E |
|