|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
( {6 F7 H6 L6 s1 nto go7 b8 C2 E: q, p3 p
if not any? turtles with [not stopped? ] [ stop ] ; ^- ^8 w) E+ ~: ^2 B
ask turtles with [remainder who 5 = 0] [
; u5 d$ `( |: d+ Aset close-mates (turtles with [self != myself])with[. s5 @$ e' w C$ d8 {
(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
; l% s9 @1 t, \and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
2 }1 D- b1 F1 T0 Jand remainder who 5 = 0 ( p7 k6 b- _" J" x) n; j$ q
]
, F7 t& K( R9 T, n& Difelse any? close-mates ! W2 T8 J S/ |
[ 6 v" T$ H8 d4 M& W2 a
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]5 n) P, t. E; Z! L! k5 u
face closest-one. ?7 ?" ?) e3 N2 P+ g% c% P: q
rt 180
: @) g9 M: |4 [, a+ Xfd random-float step-size5 s; U* a5 b8 M1 O$ n+ Q% Z9 q
avoid-walls
& S' M p, w( X7 b! V; @# W3 q+ Hset stopped? false]4 U2 R' X! i' A' {) J$ `
[set stopped? true] 2 @0 Q8 r, l+ F. Z h' ]% A
] |
|