|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序" R7 _. n* d* i3 M x
其中有一段如下( Q# |- E) x9 ]5 V& x2 g
ask turtles with [ infected? = true ] . w2 v- |- K* W
我原本以为这句会回传『所有』infected? = true 的 turtle
S( K( W/ A5 F2 B4 f- D7 ]+ Z但看结果似乎不是这样。
! [' Z" \. R# I k4 e1 k- A% }# t9 r2 B( }! Z* ?! {- `6 X
假设所有符合条件的有 5 笔
1 Y% Z4 P0 b8 E$ U: A有时候回传 1 笔,有时回传 3 笔,是不固定的
* i: w6 q5 M3 v3 J. @$ d& U, o回头查语法定义
4 r5 O; g" D2 f3 l Pwith
4 L4 \% Q1 x7 K/ z+ H6 \agentset with [reporter], d* _( w7 g+ L. a0 L, h
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.
& @( j- O( R) C3 {! Z" C它只说回传 agents satisfying the given condition& V! q' Q$ H9 b# [0 K. q: P
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? - C" q- C* t; b$ W1 ]
% F3 y: o5 e2 y
想确定一下; e* u2 u) G5 t# Z0 M
谢谢!. \6 p5 r( g+ s7 F' W3 T
|
|