|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
# z2 n+ D& |7 s6 z+ h4 m其中有一段如下6 ]( l! C6 {3 x/ F6 G; u4 E: v
ask turtles with [ infected? = true ]
+ x% U% ~+ y0 p+ k我原本以为这句会回传『所有』infected? = true 的 turtle
7 K6 K( T; W3 W( A但看结果似乎不是这样。) Y2 L4 Y6 h" b/ r. ?! i; f
X+ S. p0 H4 k$ Q! e
假设所有符合条件的有 5 笔
6 S p' s0 y+ c2 k有时候回传 1 笔,有时回传 3 笔,是不固定的1 P/ u6 X9 r- z. ~- q0 x
回头查语法定义# `8 r( c$ L5 T) ]9 @
with
5 E/ e/ D$ ~/ qagentset with [reporter]: u0 E& v5 n% i$ q- n" ^) C6 d
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.' y+ j# \7 F* N: a. @' P
它只说回传 agents satisfying the given condition
2 I: a. v% z# m( [- @是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
$ h2 J% C4 Y5 R$ K6 Z7 i3 ^ X& e7 p
+ R0 G. ~3 c! |3 t5 x+ H k4 ~想确定一下; W2 P9 M( ~) `8 O# B( i' M6 }6 c
谢谢!
3 s% }/ ^% W( U0 ^ N |
|