请问:
' k7 P# f) T1 g随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?
& B$ m' V7 F4 }- h
1 S# P9 x1 J% d- X+ w0 H+ g( E 6 @7 P8 ^. q; b! l
turtles-own [ energy ]; y* B. s) Y: g& q, ~
to setup
. @+ o5 e# z4 @clear-all) c# n: U% H l; t! z0 S
set-default-shape turtles "square"! `' O, s( i7 ]6 q
crt nutrition! n5 |- q/ R) j0 F7 L2 u
ask turtles[- I* O+ B; b' r
set color white9 ]! z' q) N! Q5 Y# z
setxy random-pxcor random-pycor]% e! B. a& ?, \$ o5 k0 Y! m/ S+ }: g. \
& R& j! K& M/ U; d0 F
ask n-of microbes-initialization patches
* z1 X5 q9 \) A [ set pcolor green] f' M/ X; p: Q' K9 a
ask turtles [set energy 1]
! U* A3 m! N7 l5 J7 ]/ r$ Vend9 [6 R, e D* l6 J
; H! W" ?( s. Z5 K( I
to go
5 ]2 a4 S8 M4 N ask turtles [set heading 90 * random 4 fd 1], }6 z5 D- a7 v7 T5 G+ [% ~; o
ask patches with [ any? turtles-here]5 }) K! u. G) r" y: z& v" ?
[ if pcolor = green and random 100 < chance-of-congregating [tt ]] S* w$ n# h' ]+ `
ask turtles [ if energy = 0 [die ]]) B. B2 o: D/ v! F; U( }0 [
end
! D4 }1 d4 a1 B5 H9 g
0 ]0 c! C. a& A+ l$ }$ \: wto tt) k9 @8 N B4 l
ask patches [set pcolor gray ]8 O6 I4 E& v$ `9 C3 H9 p
ask turtles [set energy energy - 1]
1 b& F4 J5 ~$ y- Hend
8 `3 z7 k- c7 v* G% K
5 P' l( @4 \' i6 a x# Q |