请问:
. q& a: T% r! d: v7 w随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?3 A5 H- f; N* }
1 O6 V2 n, X# V5 c7 H 5 c+ u( m) p4 o# J
turtles-own [ energy ]2 `/ e6 A; y" V" L7 Z- Z5 h; W
to setup
# a; `2 _( I1 E4 l+ ^clear-all
4 l" q3 v! s* P* n% p5 _+ D; eset-default-shape turtles "square"3 I: n9 y2 X. s' a3 h
crt nutrition
1 G& _0 C2 C. Iask turtles[2 O0 O+ j% |7 L" u& J4 C
set color white
2 `7 O1 L+ P" P setxy random-pxcor random-pycor]2 b& ?! r+ l' r& {" \' @3 I9 F3 r
2 Q( d' {/ v' N! Y7 L
ask n-of microbes-initialization patches* C a' z; d/ I0 a
[ set pcolor green]
) b/ i- s' h3 G ask turtles [set energy 1]3 b( o4 g @6 p0 H# {
end% M5 O# u; u: u( `7 z
" Z7 ]) q2 y# g2 _4 Z! L" C
to go
0 q+ q2 L; T: @: K% v) {5 d ask turtles [set heading 90 * random 4 fd 1]
; U. O$ p3 m- }( F ask patches with [ any? turtles-here]8 y8 ], ~' K$ r3 Z0 T9 g
[ if pcolor = green and random 100 < chance-of-congregating [tt ]]" J: c9 _9 f# ~
ask turtles [ if energy = 0 [die ]]3 C w- p, _" Y2 |
end
$ z! S; _6 {+ r
- c4 Z& R4 P- @ ato tt8 f! X" a# w$ [1 `$ [$ W
ask patches [set pcolor gray ]
/ e, [, d1 Z: s( z/ |' s, Z/ cask turtles [set energy energy - 1]# R; ^" ~) H3 b3 J( o$ q
end
4 q, s! u# ?% X. p5 J4 ]$ O& x: t0 [# f% d) l" ~) e$ F( B/ l; ~- j
|