请问:
+ k% L, M: @. \5 {随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?
: t } Y' J& c2 \. a( Q0 `1 c! q! L- j( D* o; `. a# l
& s- H* w# H, d8 l3 y
turtles-own [ energy ]; Q2 F# L" }4 m/ S- d
to setup( f5 b1 N4 u/ B3 p+ L
clear-all
z- H- h5 M" T: t4 Hset-default-shape turtles "square"' V5 D$ h d# z, q
crt nutrition, h( Z3 ] T' \2 f9 g! G! v
ask turtles[
7 d2 l" y: W6 t; {& I set color white; A% t/ `3 ?- \4 P' j6 [" N" O
setxy random-pxcor random-pycor]
5 \4 f! }& W7 p9 E U( ` # H% C9 l1 y5 o/ K' @
ask n-of microbes-initialization patches5 N: B, j- ~& [" G% w
[ set pcolor green]
' D' Z. U; W8 H" r* ~& e+ } ask turtles [set energy 1]0 p( \( B: b0 M' Z' g
end4 ?, Y5 \7 g( B' F* J
# g- ?2 G" i% ]% g( w! Q
to go
: B1 P8 M& m3 j8 }1 y ask turtles [set heading 90 * random 4 fd 1]4 C: i) {+ t; @+ Y
ask patches with [ any? turtles-here]
- R* U3 y( T$ N! _0 v. t [ if pcolor = green and random 100 < chance-of-congregating [tt ]]
1 e c1 h; u' _# u0 V! L+ f$ A ask turtles [ if energy = 0 [die ]]
: H' O3 i I% Q! _+ ?6 m8 L% d, k) N end- p0 G/ K4 u3 f+ }) }8 c/ H( d
1 H9 s) V; X( X0 R& k3 o
to tt
8 g* G* q f, ` Gask patches [set pcolor gray ]: i7 W, ~0 j( { B
ask turtles [set energy energy - 1]3 g# J" G* a9 C- @
end2 G$ U* ~ S$ N
" k2 ?! g/ M# J* [& B
|