|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
0 A. j8 z7 \: F5 K0 d" t3 U其中有一段如下2 G7 \! R/ F4 J
ask turtles with [ infected? = true ]
4 Z+ R/ U( H( X/ \: `7 i我原本以为这句会回传『所有』infected? = true 的 turtle) p9 L! d; j8 T3 Y; g, ^
但看结果似乎不是这样。! p9 i5 K p* V! O4 b# m7 L
- D! l- `0 w- u. ]4 D) H
假设所有符合条件的有 5 笔
8 }6 r/ _8 _+ u M有时候回传 1 笔,有时回传 3 笔,是不固定的0 P2 F2 V9 h5 _. h9 N- D# [
回头查语法定义
! A% x G. w) S0 m6 ]" L0 g2 ^with 0 |- E' F6 i+ r) A: s1 r
agentset with [reporter]
" n4 j: N6 m7 eTakes 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.7 p$ q* {% o, I* h) @: x
它只说回传 agents satisfying the given condition
5 c8 f" {0 L. v2 l8 t1 e/ s ]是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
6 q- x/ v) o: O' g. I! c& j6 C( w9 w
想确定一下
( I; Q. I* n9 U7 i谢谢!* w( e0 d J N' p9 O# o
|
|