请问:
; g5 M# e1 y3 R6 u' V% W5 h3 t7 P6 k随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?" x' U+ R9 G5 M& M
: D3 v$ w+ I- `% i4 R; g
, B( T" V# i: H) S9 t- mturtles-own [ energy ]
/ Q& I5 Q. p! Tto setup7 U. @4 y9 m8 i8 D/ o, p1 p
clear-all: u. B3 C: l0 r. E7 g1 o
set-default-shape turtles "square"( b% w$ G4 x6 E( p7 X) V
crt nutrition
- \# \; d3 I8 J, F3 ?- s/ }ask turtles[
6 q. y9 |' _( ` set color white, X. J" u$ R1 t3 R' B
setxy random-pxcor random-pycor]
" [0 }( K& |0 R& r4 m ( \( y2 ]) H( f/ ^5 _+ I7 T) U
ask n-of microbes-initialization patches
, s* h% D K% R [ set pcolor green]0 K) m- f5 W) }# o) P
ask turtles [set energy 1]4 J+ p" x( Y( B
end
7 G- i5 q& ]2 N+ [/ }" r! Z$ d- b
to go
9 o( }" {" m4 @* a2 n( @: H4 r! g. G ask turtles [set heading 90 * random 4 fd 1]- Q/ q6 p4 O; _" o
ask patches with [ any? turtles-here]
& s( W0 r0 s# n# _0 ~ [ if pcolor = green and random 100 < chance-of-congregating [tt ]]
4 a7 ?& e: O/ _8 D3 N, _1 V ask turtles [ if energy = 0 [die ]]
: w; y+ O. j# M( d, `* z end
7 z( G% z" q6 {0 B* R B% v* t* Y6 R; w6 u
to tt
. p0 e+ z9 \% Z& K% o/ t/ cask patches [set pcolor gray ]9 i: {: l9 d! A# ~( H
ask turtles [set energy energy - 1]
- w: _% y6 [; g; b& |6 i \end
8 e$ q. y( t8 r& K1 G( {
K C$ W: W8 \3 i* e8 c5 l |