请问:
" x6 n& f$ z! z随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?
6 F8 y5 V l7 P& E; u" R. B, [. G" w9 [/ s5 p* t/ V9 W- f) U
7 Y; r4 F7 l1 K5 O* \3 Qturtles-own [ energy ]
5 R$ S1 ]# j8 m( ]to setup
5 D7 s% x1 J% g4 O' Sclear-all4 e1 `* f$ E0 D
set-default-shape turtles "square"
4 R2 }4 L9 e- T" p' K; Ycrt nutrition
# x/ b* Z$ G9 V$ b5 C [ask turtles[. `1 W p+ E1 k, G8 Z
set color white( `2 t$ ?- m& R2 c3 n: Q4 n$ |( \
setxy random-pxcor random-pycor]
' n$ J* F/ B+ d: b3 K" d2 U x& N5 f# `# i$ ^% J7 o: y
ask n-of microbes-initialization patches: _7 R: F$ t5 |& t% i
[ set pcolor green]( ~$ C" i% D. ~" \
ask turtles [set energy 1]4 Z6 v& Y. v& d0 _0 l. s% F9 @
end
: c+ I$ l: y9 k4 Q0 H% M$ \) v* i7 C; X# P! {
to go- V2 ]( O0 w6 V
ask turtles [set heading 90 * random 4 fd 1]
* N8 O% m# A. J; V' S2 t ask patches with [ any? turtles-here]+ \$ x9 k1 U9 D N1 W4 ]
[ if pcolor = green and random 100 < chance-of-congregating [tt ]]# i3 M0 m* J0 ^8 a
ask turtles [ if energy = 0 [die ]]
/ V& o6 |$ n% Q. ]9 f end
' e5 N' e2 w8 m1 S3 \# `) Q0 q/ r+ S4 b6 K g5 Y0 N- Z" q
to tt
3 ]& c/ x( L- F0 D B& Aask patches [set pcolor gray ] g5 ]" b: |5 Y( y
ask turtles [set energy energy - 1]% H" S, Z- x) K& V, p2 H
end' i J2 S8 D; L9 j- Z! Z' V
" ?! B) H4 I' V, c/ X |