请问:" g! S+ e7 S, ?5 J
随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?" K3 s2 G6 A& B) D0 }9 P$ s: F# _# c
) |: i: |- M1 N+ l9 w: U) e7 e. O
2 ?! v( L! D+ E# e" Eturtles-own [ energy ], C3 q' }) j0 c7 L) U* x4 T# T. }7 ~
to setup
* i) @/ S) ?% c3 {/ U0 M7 gclear-all
3 b: j4 _9 K% Q- Nset-default-shape turtles "square"
2 a1 }/ l- E# F, \: w3 h# Gcrt nutrition
& S8 p; }5 t5 h9 E! mask turtles[
7 c4 C0 l: n2 b5 ^ set color white& [, p- C1 l+ i
setxy random-pxcor random-pycor]
' a% \# }9 U/ ~6 G+ A2 o $ x/ `* T; o8 V+ d& q6 G) r9 B/ e
ask n-of microbes-initialization patches/ w( D" Y4 b1 `( _0 l* b- P1 B( ]
[ set pcolor green]
7 L6 R, V3 g0 q5 P ask turtles [set energy 1]
5 M1 A+ l1 t& Y$ J: {3 x5 }end$ ^, s5 @" x7 u9 v+ o+ w/ o
- F9 m8 B) K+ p3 q/ Mto go
/ X$ N" J% c# A3 ~" x9 F ask turtles [set heading 90 * random 4 fd 1]& l d/ K, a* @/ w
ask patches with [ any? turtles-here]
& f1 Z3 p* o7 j, S5 g [ if pcolor = green and random 100 < chance-of-congregating [tt ]]
2 v% a, I. G3 {+ U ask turtles [ if energy = 0 [die ]]
2 \# l/ e9 u6 Y end
! l" }( B& O' _) M. C \( }/ \+ u5 f3 Y
to tt
1 U% \+ c5 ]3 ^* T5 |! R! \. D- [' rask patches [set pcolor gray ]
- g6 B" X+ q- w' q l; Kask turtles [set energy energy - 1]
) l J' W. k/ P9 yend
2 k! p3 v$ f# C4 N4 S% [5 y8 Q2 N, ?4 x/ Y5 ]& F' O
|