请问:5 N) @" u8 E4 _" i4 }" y; s/ A
随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?1 H) R" v, X( c/ ]: M
/ A9 g* M' ?7 Q* n
( b* K" Y0 q/ a6 z, L$ wturtles-own [ energy ], `! A9 x5 L; x( L2 W
to setup
/ C+ j) V' g9 w& l" b' s- Mclear-all3 i8 ^! n/ c$ G. z4 K4 T
set-default-shape turtles "square"
- A) A: R( _, N* U( x! ?crt nutrition
, a- t7 Y/ T6 v' I- r3 Fask turtles[
0 h2 Z2 a/ c2 e set color white8 `7 z$ m8 |7 a- A
setxy random-pxcor random-pycor]# u' c& \6 M% P- W1 _" h( q% x
0 e+ s- I M! N8 @8 }
ask n-of microbes-initialization patches. T9 @5 K+ P+ Q2 l7 E% I
[ set pcolor green]6 q2 D* B% H k1 H, W" U9 d9 p
ask turtles [set energy 1]: u9 ~* e5 S- p" \
end
. ?+ M5 ]5 f6 G( {# z% e9 f) f) a
to go
8 r1 P& R9 G& [ i0 |; e3 V: f ask turtles [set heading 90 * random 4 fd 1]
2 M& z/ x d" W ask patches with [ any? turtles-here]
0 o; v* h$ C( Y& g! i [ if pcolor = green and random 100 < chance-of-congregating [tt ]]% V. w5 R9 G1 E
ask turtles [ if energy = 0 [die ]]8 S$ M( t5 ?; X3 K& n( Y- j" N- `
end
: a# m" w9 I) b4 J* S$ k7 X" S" a6 t) [& [! Z2 _" N
to tt
4 U* P7 X: j* ? L, t3 v' eask patches [set pcolor gray ]/ @/ k, p* N5 o& y# ^. B; j
ask turtles [set energy energy - 1]
5 h9 |4 e6 Q7 hend2 B; ^, H7 h) C3 E: a, c/ P
4 D8 L. e3 F( g( D( G* N1 e
|