请问:
o7 w7 F* \- Y" [" G: `随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢? a' D! _3 t' K4 m/ ]) `
/ e: |4 `$ F8 u2 O' y3 d2 r( e$ V
6 i, |9 l" j1 A0 t7 U7 C8 ~turtles-own [ energy ]+ h( _, P# b* U2 P, }2 K) s
to setup
: a" @- u4 v. Nclear-all* K! p6 P# `# y4 c* l) J- J
set-default-shape turtles "square"( f, J) h& `) {! e$ j
crt nutrition4 U7 K" N, a1 Y( {! C5 @
ask turtles[9 T7 Y, e. d, G
set color white* X" F# ]% I) p: \' F
setxy random-pxcor random-pycor]
5 r$ x1 ?% s# j$ ~! u% j 7 z8 N2 r& s6 M( u1 }
ask n-of microbes-initialization patches8 x* s2 N- ?' |+ y) m
[ set pcolor green]
* l7 [; I- c" O! y, }) T/ j ask turtles [set energy 1]; a" y/ ?4 ]1 l/ h5 Z. h- A! ~( ?
end! P+ J2 A) {: u' I
# ]( j7 }' y! d( W
to go) u5 C+ O' v* `! P9 Z* l* n
ask turtles [set heading 90 * random 4 fd 1]
9 p0 I: t/ {8 y9 l7 S3 H ask patches with [ any? turtles-here]9 W- J* t1 X+ ^' k5 L
[ if pcolor = green and random 100 < chance-of-congregating [tt ]]
4 ?5 ^1 M* w" v( n5 Y5 c7 @( s$ [ ask turtles [ if energy = 0 [die ]] D, u; p! v0 [1 @; K+ m
end
5 E% C. S9 R- g( b4 i# \" I0 o( y* z; s4 B0 d
to tt
7 c! m3 B7 U0 S/ uask patches [set pcolor gray ]
1 Y0 l, ]) E- `ask turtles [set energy energy - 1] ~ Q6 d) s- W) c7 r
end" k7 R0 C1 A# \
/ G/ K) G/ X9 `9 B- Q5 L
|