|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
# Q9 | g% [8 M+ \% N8 M9 Z: }' Uto go: g4 N& H" q# q6 c" r) }& O* m
if not any? turtles with [not stopped? ] [ stop ]
& d0 D3 g, q, |, d' Oask turtles with [remainder who 5 = 0] [% c Z" a" ~% h& O7 K7 J# N
set close-mates (turtles with [self != myself])with[/ P5 E& S! S( @4 t) r7 `
(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
/ B6 f& R, Q. l' N, M2 ^and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
9 S) }' ~2 o+ ?2 t: u- Xand remainder who 5 = 0
: `3 P1 i$ i) n1 v1 k* ^] . C e: R; { ?( T% q L1 O
ifelse any? close-mates 1 l. T" f' y9 j) @
[ 6 l. w6 d9 b6 I% d( i3 T
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]
* Y8 ?1 y6 T7 J" H. `4 T, Kface closest-one+ u: K/ Q; ^) S) S+ D7 G; j, c
rt 180
1 D4 Z$ I$ n8 i( ~9 [% m: Lfd random-float step-size9 K: Z" f F4 a) {: _
avoid-walls
5 o w3 @" _, {set stopped? false]
1 K4 q1 z' K i[set stopped? true] ; `' D' o* V5 ]+ b% A, z3 ^' m
] |
|