|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false% J% X$ N- h/ b z
to go
0 A. Q2 e1 o7 N5 G4 w9 ]if not any? turtles with [not stopped? ] [ stop ]
/ Q- _4 f$ x0 w9 t# Pask turtles with [remainder who 5 = 0] [
N! g- O, U- X: y; b% F7 K7 Pset close-mates (turtles with [self != myself])with[
5 N% I0 U, Y* |(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) : n) K% F) T, y. ]$ J4 y
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
% G5 o3 H% ]. q+ Hand remainder who 5 = 0
" o; O! i- @& J T" L% ]] 5 a' g6 z" m' H; {1 Q* r
ifelse any? close-mates
3 X6 z% R% W) [% y! t[ . s5 y# v5 W% L. r
set closest-one min-one-of (close-mates with[self != myself] )[distance myself] t3 ^& V5 q4 J9 W! U0 o8 Y
face closest-one
2 H$ v; q. z$ ^0 zrt 1801 G# B& p! c& i1 w8 O
fd random-float step-size
7 s' q' O$ U% `7 s5 D/ {avoid-walls
& _! d3 R/ _0 g0 [set stopped? false]& V" A( M$ m5 I9 o! q+ P. ?$ k
[set stopped? true]
5 j0 d! |% }2 [/ L/ w: b( t' U] |
|