|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false: Z# G1 X2 [, I2 m( R1 [$ M; s2 w/ L
to go+ ?+ e0 Q# j" f( U6 M1 \, Z1 V
if not any? turtles with [not stopped? ] [ stop ] 3 Y2 q' Z; S% v. ]) G
ask turtles with [remainder who 5 = 0] [8 j* J6 ]* |8 B5 S# A6 q0 ?9 X$ N
set close-mates (turtles with [self != myself])with[
9 D3 j- O: ^1 l4 Z) e2 `/ m# @(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
( h1 _& a; s) s9 u( G2 hand (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
% y* b5 B" G$ k1 Mand remainder who 5 = 0
0 y& T$ z9 e7 q$ A+ O) w] - v4 K& b7 v# ^ }
ifelse any? close-mates $ b3 Q! d) x& [3 k2 o1 _9 v0 J9 `
[ 5 P; ^7 `1 U0 [
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]
# I& I# U3 Q" `- _9 Bface closest-one3 Z: t! q# Y2 j) f
rt 180$ P- h7 w# D) R9 V2 B) G% [6 h. m) a" d3 b2 j
fd random-float step-size
, |+ J5 b4 ?& i: g# v# Zavoid-walls
1 ?! s4 K& [( L. s! Z3 D8 r K8 T# rset stopped? false]5 v" A% u: u$ l
[set stopped? true] 6 I$ L9 J! Y, g9 |6 K. G+ h
] |
|