|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
0 k9 h+ M) x& Wto go
- C/ }, P8 n$ v# t4 J/ ?$ D1 U6 Fif not any? turtles with [not stopped? ] [ stop ] , ~0 F' y1 W7 W$ S6 G
ask turtles with [remainder who 5 = 0] [
, n6 E j' _; ` S3 B" h7 xset close-mates (turtles with [self != myself])with[
8 c- a9 g E7 z(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) - d. t9 {$ W7 R: {0 s* ]
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
& t7 }* t# i- ~0 ^and remainder who 5 = 0
. k! W: }. K I0 F4 Z8 {] * t7 K% ]4 Z8 }0 u
ifelse any? close-mates
. \7 o, U9 ^" t K% K; q[
8 f- s# W6 m/ u9 H E3 b0 }set closest-one min-one-of (close-mates with[self != myself] )[distance myself]" ^4 I; Z) x$ d. R
face closest-one9 V+ D! }; z+ {" Z! h4 D: h
rt 1807 [0 P5 T+ a( V9 d: h# v* q$ W
fd random-float step-size! A) Z6 w4 P. W- D# i
avoid-walls
+ {% p! C) @3 m) x+ ^set stopped? false]
: h$ O& x6 I( {3 F7 G[set stopped? true]
( o9 c; Z5 e' Y2 D% ^0 t r] |
|