|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
5 ] A/ S. E4 Rto go* _. T$ }3 W. |
if not any? turtles with [not stopped? ] [ stop ]
" m* l* W9 b5 D9 Cask turtles with [remainder who 5 = 0] [# Y; q3 _/ ]& R9 f2 C3 h
set close-mates (turtles with [self != myself])with[
4 a7 N! l8 J8 }3 `: G(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) 0 l9 g' `* {# q6 o# H0 b
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
7 e' s7 F/ b1 K3 C) a! T9 q7 Gand remainder who 5 = 0
! r! }) t% [7 a1 i7 ~8 r7 g] ! ?0 m3 V2 Y: w8 G) L
ifelse any? close-mates $ i% r" M! n! r W4 ]9 G) z0 I
[ , t' R9 m5 Z: L! i/ W( H
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]/ S; x) _; N9 v: A; V0 T6 z) c
face closest-one. |& g& e6 }& t3 ], L6 @
rt 180
8 D( e; O. W3 K" b% x5 ]6 K: w6 tfd random-float step-size
6 O+ K( ?. X5 i% x s* j# `avoid-walls, j: p u0 z' q
set stopped? false]8 [( C# K/ T% y7 c: [
[set stopped? true]
% u2 C8 E+ h% T8 [, g3 c] |
|