请问:
7 Y1 F- ?( y, {% Y. t) x) K随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?/ @' Y4 u) J$ c
5 W# [4 i. ~! Z3 N5 m a. k/ B; Q; @* o4 b3 v) ~+ N7 K
turtles-own [ energy ]8 B: Z- R' e' ~5 o, |
to setup) V- l4 J4 A6 i L; ]( t x) s; {1 D
clear-all% N3 m" E4 r6 A t! K
set-default-shape turtles "square"& H, t2 N' J) a
crt nutrition) J+ s( _& n( ]1 n0 ?
ask turtles[+ e8 A7 M+ |" |2 `: m9 B
set color white( a" {" [; ?1 ?" X
setxy random-pxcor random-pycor]
& p8 G/ j9 Q; A9 _8 @. K+ D $ C* `* j6 [" S" e' E' M3 j8 M
ask n-of microbes-initialization patches+ O' I# K0 j+ L+ Y( E9 P% T" B1 y
[ set pcolor green]: w5 J% D) Q& N$ D/ X+ u
ask turtles [set energy 1]% a- `/ B4 S7 i' |( D
end
6 a4 C7 n- P- P! _2 d
' n: g% O2 [1 n* ?3 O: i2 x3 E4 Sto go
% ^' c2 z! o/ z4 [* k* D3 | ask turtles [set heading 90 * random 4 fd 1]
& |0 _+ P- n* @% G/ D9 p ask patches with [ any? turtles-here]
- V9 D; E o, K2 j7 D! O [ if pcolor = green and random 100 < chance-of-congregating [tt ]]& I% A$ Y l, n" Q+ f
ask turtles [ if energy = 0 [die ]]% g4 E8 R; k3 r8 i) x
end) D& V/ _8 \. o! [% \0 k9 g6 c
7 w4 e/ q: F8 _6 }6 T5 tto tt' D5 o7 z" v2 a1 }; A
ask patches [set pcolor gray ]
: B: F+ y: ^" Gask turtles [set energy energy - 1]1 P2 e# j: e9 p4 N
end
0 [- h$ K" i; v' s+ b, q% `. |
/ `2 G1 M6 z: h' t8 m |