|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false$ X4 j) O, F4 ]2 I# A+ V5 ]
to go: m- E9 B* @9 y: S
if not any? turtles with [not stopped? ] [ stop ] $ b1 o, N n4 K/ s/ v3 N
ask turtles with [remainder who 5 = 0] [3 |/ H# {$ s/ u0 W
set close-mates (turtles with [self != myself])with[
. G, G! B6 v$ e5 }' m( n- s(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
! n& n6 \- `/ `5 `% A% j8 jand (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
1 P# P8 Y+ U/ P6 A5 C; Sand remainder who 5 = 0
6 |0 d$ h1 l! a% H8 j/ F2 ]- ^ t6 Z]
9 I: ?8 I; }4 s3 K/ |5 @5 M9 Z+ g5 bifelse any? close-mates
* l& Z# A9 B; ~[
. n9 z( L! K. l$ K# {6 Iset closest-one min-one-of (close-mates with[self != myself] )[distance myself]5 v8 A* C+ b& ^+ p4 _/ L
face closest-one: z# @' V# Q4 N9 f T- u5 }
rt 180 y2 z. \: e. l8 J/ \
fd random-float step-size
9 l% v- C$ V Z1 S0 b4 Pavoid-walls0 D1 _# Q! P* W
set stopped? false]
4 i+ N7 I+ j3 x" j' S[set stopped? true]
4 O# \7 {, ]) R( b3 J6 |5 r7 I] |
|