请问:
; h+ E% f3 E8 |; _# ~( n随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?% w' m/ o+ w7 _5 F$ H5 q# T2 _5 A8 @
" `1 ~! D" t$ u2 P- Q! T
?: n) R. Y& tturtles-own [ energy ], F9 {0 a$ l# i+ A- ~/ E8 x, @
to setup
5 n7 H; s j& p6 F0 Xclear-all1 J6 X7 Q" x2 R5 \! p, s5 Q! ?
set-default-shape turtles "square"9 Y" l$ u: J; K. m
crt nutrition
, ]+ d8 ?) n% m# U- ^/ Pask turtles[
, G: H/ E; f' v1 S set color white# e0 p, {! ~/ T8 Z) }$ U
setxy random-pxcor random-pycor]& C- ~" |% |1 Q' y- M# c: G
S" l% s3 V7 d, Jask n-of microbes-initialization patches
$ R- A: v. g s [ set pcolor green], N. |+ V) s' [4 J7 U; f7 d% J# J! ~
ask turtles [set energy 1]1 f2 o7 s7 `9 v; O6 c* k
end8 ]5 c6 j! S' g5 V+ i3 f
$ o4 m) C6 J7 Q- M( Gto go
: D; M0 M7 I* g. L; a K& }) k ask turtles [set heading 90 * random 4 fd 1], o! U% L( X7 R
ask patches with [ any? turtles-here]
, K0 g1 a/ |6 a2 f; d [ if pcolor = green and random 100 < chance-of-congregating [tt ]]1 S- W* z( T0 m9 @7 B5 `
ask turtles [ if energy = 0 [die ]]
2 D9 b4 y! t) M' ]& Q end
& H. e$ }) v% |3 J& Z4 r5 j2 C! K% N8 }: Z) s G
to tt
: A9 l# `; z5 x: N: nask patches [set pcolor gray ]
/ r* U: d+ i- Y" _& Q+ fask turtles [set energy energy - 1]" p! U7 ]3 x" ]* \
end
" h4 E. {& ]" |* B9 l: R8 {' H/ s9 V5 ^" ]2 m0 w# D
|