请问:- I4 ^- e3 p1 }5 B" E) ~! [
随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?) b, Z. o0 L( I0 I. i* @5 f K8 w( T
) h; ?3 Q8 N. X$ b ? H" K# ?
; u7 y. t( c T& v/ i; H0 H
turtles-own [ energy ]
" s4 L6 l: l# h. Sto setup0 {" @1 F. V6 X4 q9 \% E5 m! u
clear-all
4 o: m* Q& Z2 R( h h5 g/ cset-default-shape turtles "square"
) M, L& A4 V3 n& _crt nutrition
' s) m2 `* {$ n$ G8 b( nask turtles[7 j; I$ j: H5 }, U& B
set color white
- E- w+ l! t( j7 P. N- k4 t, [0 p" g setxy random-pxcor random-pycor]
; ] k- b" ^9 p# E( G
3 K; G/ ?' V" F+ N2 |$ I* bask n-of microbes-initialization patches
) d$ g3 G/ P$ a6 ]" ~- s2 W1 c- b [ set pcolor green]+ N/ p6 S, `/ F8 B2 J& E
ask turtles [set energy 1]
+ W. ~( [* U1 o" O' E0 b5 c& @6 A$ Vend! Z- a! k: t8 F
$ V" V: c5 F8 e
to go
' O( r+ k: x0 n a ask turtles [set heading 90 * random 4 fd 1]
0 \% d: {: |6 {, r& s ask patches with [ any? turtles-here]2 Q2 \7 j0 X1 `5 P7 P' m2 o) D
[ if pcolor = green and random 100 < chance-of-congregating [tt ]] A4 D8 c' s$ Y$ I# f) j7 C6 p
ask turtles [ if energy = 0 [die ]]9 U& }8 }3 I5 R, i9 M
end- i7 j) s8 Q( e- W: d! W+ a
( n% K1 c I7 k2 X. q3 Sto tt
4 D- ~ w; _' u. ^- vask patches [set pcolor gray ]
% T+ q9 _+ j+ Y/ h! L8 lask turtles [set energy energy - 1]
) n& } V( b5 Y5 p2 t* N1 T9 Wend
4 s8 |) [1 j+ I2 h c F/ w, o+ i, Y+ ^
|