|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
2 ?; V6 W F3 V U7 w3 z% Cto go
* `7 K7 |$ ]# I. m; T8 Y& ~if not any? turtles with [not stopped? ] [ stop ]
( I- O- U6 b+ R+ u: A' }( cask turtles with [remainder who 5 = 0] [
/ y$ O( _5 [/ v3 H# wset close-mates (turtles with [self != myself])with[
. V: Y) ~6 o8 m9 {* H8 D% B+ X5 q(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
2 e2 [; T, _. Y, kand (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) / k- _3 M+ j" o
and remainder who 5 = 0 / v' _/ M m/ o
] 5 @3 b. y6 o) \4 P: P0 k1 q' r3 N0 P
ifelse any? close-mates 6 R- \7 F; x0 w- y" l" V) |4 I
[ + D1 o* m1 \/ E O; L9 l8 D8 {* P4 a
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]
5 i' l7 ~ V3 ?3 I0 Oface closest-one
- q2 {' H) t0 T6 u& Ort 1800 o9 N. j; V O8 d
fd random-float step-size0 J& T. l% [! q3 H7 M O4 A0 h
avoid-walls
, w' |+ I/ `# J4 \set stopped? false]
q/ h, J* s9 d- I5 {+ d$ U {( l$ h[set stopped? true] 4 P x# ?* Y* G1 V* Y y" A% S
] |
|