请问:
; ?3 B0 I* |/ b6 `. W: ?随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?
# S% T& E4 _, d. x
# |9 E% H. J+ D: {0 t( c2 |' V / z( h- K* }4 ^/ m; V6 K% U
turtles-own [ energy ]
1 V4 s3 ?/ T& k# R- wto setup
, M6 W4 Y& q" d1 Xclear-all5 M5 [2 D( ]1 V- m9 T. O2 \
set-default-shape turtles "square"
& {( m% j% ~ m: |/ }& tcrt nutrition
v( i( m6 J9 _4 |4 P, o6 Task turtles[
# ^( P' {2 Z$ @! Q set color white) O6 S, Y# a) Z4 I) t/ X4 ?
setxy random-pxcor random-pycor]% O. _9 }; D, ~4 ]! U0 L" G) z
, e, t J) A, L, o" y; v9 \; f0 l
ask n-of microbes-initialization patches
/ H! B x: h; z! [ [ set pcolor green]2 ~# L4 O. U6 [# W/ P+ }2 C* Q
ask turtles [set energy 1]
3 V' _& ?+ K% iend
+ y& G: V* v8 g" @, K: w, _9 e# z
to go
. f$ v* L- w$ \0 W" H4 M9 N ask turtles [set heading 90 * random 4 fd 1]2 G) V7 q0 u+ f' s' O
ask patches with [ any? turtles-here]. \ W1 v' b x C. W" o
[ if pcolor = green and random 100 < chance-of-congregating [tt ]]
6 W+ |' e+ V% | ask turtles [ if energy = 0 [die ]]9 {2 u+ |+ \& `5 Q# F' a
end
' P; J1 d) h$ y9 H4 p5 p! e& w& e0 g5 C+ Y( n% }& ?
to tt
' Z5 r% q! W. A/ R. {" u/ u( O* cask patches [set pcolor gray ]
; Y. S8 Y( k+ Y4 a5 N5 Cask turtles [set energy energy - 1]
: T) x; w7 S5 s/ O) E3 C! ~8 Aend
" f/ h' d3 w( r: V( R* f, s& @: m
+ Y K' ^# J9 K4 z9 n5 n/ q |