请问:
) O+ A8 J' G/ S% Y; T( C8 M/ R随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?
2 z4 f* h) e5 U% V0 R9 M4 s9 X+ \( B$ z3 ~. {* }) X( C& t
1 K$ c# |) M2 k7 a6 v
turtles-own [ energy ]; Z# k7 B5 k' T: ^- a
to setup
) N% m+ ~4 J( lclear-all: Q5 G+ o% ~: w4 m; }: A
set-default-shape turtles "square"
! S' I6 w M% F' E& _crt nutrition, \2 l0 D$ _2 s8 C) H$ c
ask turtles[4 a5 F) M( ?* V# C+ L4 H' ~5 i6 S
set color white, L" C2 S+ V6 z( p* L( [' @
setxy random-pxcor random-pycor]- E2 s0 K5 q4 p, A) r
: ~2 \7 F. v- X' V5 e$ a: Zask n-of microbes-initialization patches
# {6 J* z1 Z+ Q, R/ V- C [ set pcolor green]1 n4 R4 x7 R) ~- z) `+ { d
ask turtles [set energy 1]2 `6 P& H" u& a$ g) T z# p; ~3 t
end6 p f! V& l+ a7 ^
; h6 ^: m) V! I7 e: N' Eto go# v+ Y3 y2 t1 @9 O( `
ask turtles [set heading 90 * random 4 fd 1]
V$ I2 W/ y& R, v/ n( N ask patches with [ any? turtles-here]5 W5 x: R- u1 S4 D: V9 h6 |) @# s( \
[ if pcolor = green and random 100 < chance-of-congregating [tt ]]/ \- K- S0 ^ O- n# }4 b( O
ask turtles [ if energy = 0 [die ]]
+ @4 B$ C: o; E# p end+ p/ s0 F. ~/ j" l
+ l+ D; n. R9 n- K$ g
to tt
' v+ y; V' r, j, [2 C; d% |ask patches [set pcolor gray ]
9 B6 W9 _8 v Y2 O+ l _8 hask turtles [set energy energy - 1]
6 D- m |: W' M4 j4 ~& ? Rend! Q0 Q( F0 F* e4 R
1 A0 Q. {4 l- e |