|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false. i. P4 h+ L! v; C* {
to go
% J2 K' h3 o7 k# ~5 Yif not any? turtles with [not stopped? ] [ stop ]
' s; F4 _- f$ D) J; q4 _" iask turtles with [remainder who 5 = 0] [
$ [3 Q' Z5 m' sset close-mates (turtles with [self != myself])with[4 P( F0 ?4 L3 `2 s: ^; C
(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) 4 g0 C& w2 j( j2 P9 o
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) 5 ~5 D( T* K, c% r, l5 z
and remainder who 5 = 0 # F) s ^9 a& L9 k$ t- ~; L5 D7 h
] 5 d r) @) ]0 y3 \- z
ifelse any? close-mates $ P' \' A4 w O% {) a
[
! _1 }$ |8 h- }set closest-one min-one-of (close-mates with[self != myself] )[distance myself]5 } A0 _4 L8 a$ D
face closest-one
6 ^3 |3 H) X) s4 F3 u; drt 180# g$ V W- [7 T0 d9 b# ~0 @* `2 l
fd random-float step-size4 b) u% N2 o, R
avoid-walls3 i* k! E5 Z; u- Q' O0 |
set stopped? false]8 V- H: r& M0 U7 O u& }8 h8 u5 k1 g
[set stopped? true] , h* }5 l3 k4 q1 o. @
] |
|