|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
% p# q" V1 X4 H* Dto go
: J! E G; ^3 a+ C, i9 |. Hif not any? turtles with [not stopped? ] [ stop ] ' n" G$ h' C, {- H5 t: a+ y# T' [) T
ask turtles with [remainder who 5 = 0] [
# g& n0 H4 |' w- Z. V p9 \set close-mates (turtles with [self != myself])with[
! h# K- L) w4 w: t6 v# t" ~(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
; B6 x2 o' d6 ?and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
! ~2 f: S4 n! [# E) Band remainder who 5 = 0
6 W; h* R9 q. _& w/ ]] 9 Y4 S/ O! X# J1 c
ifelse any? close-mates
+ s% Y* F, s% z1 ]+ C" ][ 0 q8 x6 T+ N% ]/ Q0 Q
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]
" d3 q$ Y: z; p k' _face closest-one7 P8 M8 _1 d4 p; P1 N g
rt 180! T2 I- X3 O2 X$ R% \! Z
fd random-float step-size- ^ y- h1 o5 M# @: `- ~2 [4 \8 V/ N) {
avoid-walls
; E" S) ~6 f. l" Nset stopped? false]: W4 X: y) k) K5 l: }/ O# x- ^
[set stopped? true] 7 B; B- h, I' V4 K8 }* V v
] |
|