|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false% i& B0 u, M7 c) |( h: c1 }
to go
: `% r5 t( r; s2 x" d8 V# tif not any? turtles with [not stopped? ] [ stop ] ( o) ?' t, k9 j; F8 y3 L% S/ Y
ask turtles with [remainder who 5 = 0] [
7 c) S3 s; u& T; a* [set close-mates (turtles with [self != myself])with[: B! F# D- ?! J1 P$ j# ^
(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) 4 _$ {. y& o' p& q
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
* @9 R# V3 [0 x/ `' qand remainder who 5 = 0
- N3 Y0 C7 @' t3 q/ i]
4 o" w2 V0 e3 F$ p: v% Zifelse any? close-mates ( ]: }4 Z0 `4 J3 {+ _ P% R" j
[
9 C8 O |/ w; m: {* E3 P& lset closest-one min-one-of (close-mates with[self != myself] )[distance myself]
4 P% {2 }3 n9 C7 |0 W! nface closest-one
. g9 G! j/ x( ?rt 180 d! P( o% D; l! J- R% E1 W
fd random-float step-size
: r6 o) E8 h/ J4 v \& Vavoid-walls0 T- n& U7 B3 ]- p
set stopped? false]
' Z6 v: N. y! e9 t5 R7 F8 A: A; A& {[set stopped? true]
, x, Q9 v9 e# ~1 k: ]] |
|