|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false4 N* v; i3 T& V3 h/ ^+ b+ G% f! U
to go
6 B4 J; ^( L6 _$ p, Gif not any? turtles with [not stopped? ] [ stop ]
6 u, o3 ~2 ^9 H( u0 B4 W' Uask turtles with [remainder who 5 = 0] [
! {0 r* h$ l8 ^1 A0 kset close-mates (turtles with [self != myself])with[, ]+ n+ m' N* ~& K5 |9 g s6 q
(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
& t4 I8 t0 M# N# `and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) ( ?, E% ]/ _& f `: n* O
and remainder who 5 = 0 9 \/ U3 q7 Z* P1 {( T T
] . W6 U5 E8 M# ?% B& s# U0 O
ifelse any? close-mates " D$ b9 F4 N( `" S X
[ 1 r! ^' k+ ^* c- C3 u
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]
$ j4 E- z8 {4 {1 |( B g l5 zface closest-one( }! s' M7 V- k4 @( r8 S S- H
rt 180
% x5 [: N" n: r1 R2 ]: z3 Qfd random-float step-size( z- d) C* O$ w% V& ]3 w1 @- P( L0 t
avoid-walls: d9 u, ^ c8 s
set stopped? false]
D8 U+ A" q5 t: c( K[set stopped? true] : K) k! H; l/ k) q6 |, @
] |
|