|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false1 A& D' K; n# W4 G$ Y7 u
to go
B2 ], X7 ?" Tif not any? turtles with [not stopped? ] [ stop ] / N/ Q8 h" J( p( F( ]6 E8 ~
ask turtles with [remainder who 5 = 0] [3 V% ~. u h T- r
set close-mates (turtles with [self != myself])with[
& g5 \, H4 X5 `& s7 S/ s, i& }(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) 2 O+ m$ B" f1 \2 N
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) ! ^0 j6 p5 G0 m: z8 c
and remainder who 5 = 0 * `1 l& X7 d' }! I F5 T. M3 r, l
] 5 P9 Z8 i/ Y2 o/ Y
ifelse any? close-mates
; I5 ^: s% I f4 K( e5 V[ " N2 N( [2 T! o$ C, v" N1 M+ U8 ?( K
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]
5 N% ]3 X0 m6 Z$ Pface closest-one
( e$ ]: b2 C3 v# x: M, U: T' O" N. {rt 180
6 x$ N/ [7 r0 B0 B/ Yfd random-float step-size
" E3 l& ]" A, A# havoid-walls
. {& a1 ]2 t6 P/ ]0 u, R5 y( W6 ~# Wset stopped? false]* h: |5 W" g w7 ]9 r
[set stopped? true] 6 L8 G+ b- W# v6 G! S9 A j0 j! T+ `
] |
|