请问:
4 [' A) I- M0 w6 _7 D& m随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?
2 G' U. ?, P7 B ], R9 z
4 h" f8 f0 c' F) t' q8 }% O. z 4 ]+ M) v6 _2 M. i9 E' G9 N
turtles-own [ energy ]8 g0 e1 V [, \% m: g9 v9 d4 r
to setup
# n2 P) j! b, e- s# F" \clear-all, _% }1 `# l3 X* x" p
set-default-shape turtles "square"
# D: I5 P7 N& v8 s9 _; Pcrt nutrition4 h- Q+ Q: \. g9 s8 E0 R, v) _
ask turtles[5 ^5 ~6 \- f" D6 ?+ r
set color white
* q) g; Q* ?6 r setxy random-pxcor random-pycor]$ T, w4 g% g" O6 x: K
+ M0 s6 W3 M9 s) p$ g0 n
ask n-of microbes-initialization patches
$ y4 u1 r; s& W f [ set pcolor green]& W# o$ J& u- |' ]8 G1 U
ask turtles [set energy 1]; n8 f0 w( g- H
end
7 i2 @0 Q3 n" \8 _2 C" P- u7 k& c+ V
to go1 V. w: |; S6 g; [6 K
ask turtles [set heading 90 * random 4 fd 1]" L; {9 c9 N' q% V
ask patches with [ any? turtles-here]2 P" ` ^& J3 k8 a4 L2 y% [9 q
[ if pcolor = green and random 100 < chance-of-congregating [tt ]]$ O- q8 X. @$ m6 } e5 b) L( y
ask turtles [ if energy = 0 [die ]]5 n) T( W5 A$ ?$ z) w
end9 l. f8 @1 T+ v
0 ?! g4 X! J+ p' G5 u
to tt
6 a w5 J; v1 xask patches [set pcolor gray ]
! q9 c( H5 M) z3 L2 H5 `ask turtles [set energy energy - 1]- |- |' j7 @4 [, R7 ~( B
end, d# j% a ~" W+ E
: l6 I$ o1 ]0 s3 ]- p+ z
|