|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
& L5 Z- J. c1 ^3 w( \, R! ^7 @/ u. _to go Z2 Q; W& K5 ~9 c' r2 Y
if not any? turtles with [not stopped? ] [ stop ] 9 Z6 H8 Q& ~; D8 C
ask turtles with [remainder who 5 = 0] [5 R% V+ }) }% Z' B/ o
set close-mates (turtles with [self != myself])with[
: G9 U' z7 \) r(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) 6 t- j9 N9 a2 V5 W, B3 i( Y M
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) 4 p$ e$ I9 P8 R& x
and remainder who 5 = 0 9 b1 D5 D! p0 [, C- x- Q7 ]+ Z
] . y' c9 O3 f2 |- U1 E; _
ifelse any? close-mates / d% q7 y0 D* o. r
[
& c+ A3 }6 J* ]set closest-one min-one-of (close-mates with[self != myself] )[distance myself]
& }6 }5 Q6 T" A! iface closest-one
( s3 |# v) g" B1 `/ T$ ^0 x; T1 ]rt 180
& ]0 {: Z( d% j- i/ I' U8 t8 L3 Afd random-float step-size
! R* X B5 c" M. I7 y7 `avoid-walls
$ Q7 k: L/ c( `, F C3 Mset stopped? false]
/ `, f ?+ Q+ R- }! D0 P& D[set stopped? true] , b: `; c% m$ o4 U. P+ ?6 {9 b
] |
|