请问:
) A, r" _# u( B) b" I1 u6 G随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?
" p" l* [+ \: ^' R" Q- t+ h
2 R; X( y2 F) A % S- o$ K D, s4 w3 V# J
turtles-own [ energy ]
( z: A7 m& {5 t# p+ Ito setup
# Z/ E1 G+ L8 c* y; u$ s( [clear-all
$ X: D4 W4 w$ B1 W2 w+ ~& Rset-default-shape turtles "square"4 A( z' E6 t7 \) I9 n# G3 |( z
crt nutrition7 d& N8 _0 T! H' N
ask turtles[# Y+ Y# [/ w. N- p& D4 S. p1 V/ q! L8 ?
set color white
- P3 {- j; e' h ^. K5 E$ b setxy random-pxcor random-pycor]
/ ~8 y7 Z% a4 t9 ]& V, a( @
]2 Y, l& ^. w3 s& v7 h- v% {; dask n-of microbes-initialization patches
4 R, {" O1 D( b' I8 n [ set pcolor green] O) Q) Q7 [5 p/ S5 F
ask turtles [set energy 1]
6 @- s4 j9 s2 L5 w4 F' V/ F* Yend; f8 q9 {: k' z! F" ~$ E, ?
2 Z5 _0 r7 P V7 O Hto go! z2 R- L6 _8 O
ask turtles [set heading 90 * random 4 fd 1]
* W# }, }" X$ s ask patches with [ any? turtles-here]+ ~9 s0 \3 _! Q5 u. P) p! G$ J
[ if pcolor = green and random 100 < chance-of-congregating [tt ]]
9 `8 _- D# A7 e/ P% d9 p ask turtles [ if energy = 0 [die ]]# y* V7 A1 s9 ^" A( x% K
end# |8 |; c( T, T! p5 B
4 w: U( T0 c# ]8 N; A# n
to tt
* N7 V/ a4 x* V0 @: P6 j* o. Qask patches [set pcolor gray ]& ?3 P# r3 p. d: j
ask turtles [set energy energy - 1]
- u, l$ N- J; pend. f! H9 |$ x- y4 Q
$ N/ u, T3 X5 v' y |