|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false" o% G4 }% p, ]) s1 M4 \& u
to go
, {7 y3 M6 B9 z) l qif not any? turtles with [not stopped? ] [ stop ]
# F4 r, ?# W: I: E: z6 wask turtles with [remainder who 5 = 0] [
; @' Q A: q# v6 y3 w8 Eset close-mates (turtles with [self != myself])with[
( A6 c& F9 K4 V3 ^7 R" o(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
' x: w' J, a% U, u Xand (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) / |, L* Y/ ~0 \! e) y
and remainder who 5 = 0 * q1 W+ z+ f" e! t9 v
] 6 n6 ?2 `4 R) y7 y, Q; h
ifelse any? close-mates
% A& i$ e4 Y$ y4 R[
9 ~- N2 C& t \set closest-one min-one-of (close-mates with[self != myself] )[distance myself]- R+ s1 k. J6 o/ ~. t
face closest-one
q# a8 @* f4 [0 c' Rrt 180
+ b" J! T0 g3 l: }0 Ofd random-float step-size% w$ p+ R8 e( K" X) C2 ^9 q
avoid-walls
! q0 U/ P( q( o' c) Sset stopped? false]
+ n7 \. `4 [0 L) g1 ~! F) A( V, i; f[set stopped? true] ) k+ C& B9 a. w- [' Q
] |
|