|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false) b; B/ ]2 n! p1 H
to go
5 B' T0 E2 S: a7 `1 r: Yif not any? turtles with [not stopped? ] [ stop ] , v# o. @+ Z4 L: n
ask turtles with [remainder who 5 = 0] [
; F) W3 S# t( B/ X. K0 _set close-mates (turtles with [self != myself])with[$ Y' t" c/ G! E6 a( `" b9 ~4 ~; T
(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) & w2 |- t u/ m2 U1 X9 G; i
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) 3 x# i2 _% G. v9 S! X
and remainder who 5 = 0 : b7 N( X9 K/ U& a
] 6 y5 e/ R9 |) G
ifelse any? close-mates
j4 [; `& L1 A( ~7 \5 G8 ~[ : F8 ]& S8 ]% k6 I s: w6 A0 [5 t5 q
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]
( p9 y$ B( u! y2 L" m, t! r* bface closest-one! q x- O& B* w4 o$ H
rt 180
8 d: Q/ j! ^2 E' _fd random-float step-size
7 F- }; l' H; h [avoid-walls
5 R. v# @- f; @+ }" S+ u, tset stopped? false]8 w; O# K* U# Q" d* k
[set stopped? true] 4 h2 v6 T" z! n6 m
] |
|