|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false4 X& u7 q6 k" I9 l
to go
- X% S( D* d) ^& m& Wif not any? turtles with [not stopped? ] [ stop ] % q o, k G$ q5 u4 F: N1 E
ask turtles with [remainder who 5 = 0] [4 s5 @) l/ d6 m* |
set close-mates (turtles with [self != myself])with[: W( w, Y& b9 M0 I5 `
(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
9 g$ c2 ^* p# f. _% Y7 H2 band (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) ' @( Q3 r9 T$ t* d
and remainder who 5 = 0
% S: o+ ^4 ~- F2 {$ z] . q7 a; t6 n& n. W* ] i2 P
ifelse any? close-mates
8 N: l( {5 E; c" V) [$ p[
! x2 l) N2 V. m4 h* Pset closest-one min-one-of (close-mates with[self != myself] )[distance myself]% N" |, I# R7 L2 @3 Z
face closest-one
8 L' P) b0 f) P4 q* A8 V" ^1 [rt 180
, P& ~5 O! M0 P8 ] H3 Q. Mfd random-float step-size
0 p5 b- {( [& d# D3 iavoid-walls
/ x' D+ y# u4 e# T4 K6 ]. hset stopped? false]4 I3 M% l; E' w r0 P Z
[set stopped? true]
/ u) x0 }1 R) U8 B Y2 h] |
|