请问:* t4 A( q J5 ?* N7 ?" c& i
随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?' Z4 l! C+ F+ j7 O, @3 F
5 [$ V# M3 s$ P7 Q
" d& {5 q$ u" H0 y7 K+ C: _turtles-own [ energy ]
' L1 P" `! `0 E& ?# Z9 | s) qto setup
/ o0 d T0 g5 ^, D( z3 k( A; pclear-all
$ y& s3 b; a% Y$ gset-default-shape turtles "square"
/ Z( f8 @) c+ {crt nutrition. V. q7 B) w9 V3 U0 A$ u9 F$ @
ask turtles[
* y$ Q% s* s) g z3 ?/ Y7 x set color white* A+ e h) @' ?; W4 F) I& c, [( p
setxy random-pxcor random-pycor]
8 b* ], u2 j' y# j' j" F/ G # I" J. ]! g- [0 `* |6 R
ask n-of microbes-initialization patches5 ~, g% ^/ [2 U: c4 c1 a
[ set pcolor green]
M* ~# D. a7 x* @4 q ask turtles [set energy 1]
3 `, _/ e4 j5 y* u. M" R% zend
" P) ?) p) Y2 i' K4 F2 B
2 j" B, W* m: E. d. V' V/ Uto go$ M; u+ S+ F( @1 ^* N! I7 |
ask turtles [set heading 90 * random 4 fd 1]6 o4 F1 d& \3 g; g; D3 |
ask patches with [ any? turtles-here]. x. z, h4 A `4 ~0 n1 L }! c `
[ if pcolor = green and random 100 < chance-of-congregating [tt ]]
' J! P# L8 [9 \4 g ask turtles [ if energy = 0 [die ]]
0 L, Z& G" j' B$ n+ m/ v end
# e0 ^6 i! m1 E3 r) ?( r$ |! b! o6 M& o2 Z' Z3 D' s" J) S
to tt
5 p. _: }1 k7 U1 Q& Y" Dask patches [set pcolor gray ]2 x" p/ z. @& h) w! _. r) |( @
ask turtles [set energy energy - 1]: D, [: w( r6 h! `3 O( N! u1 j5 m/ Y0 f
end+ K2 T( @7 S/ {, X* X5 U1 @ q
3 w( D& T1 K, D, s" \. o( B |