请问:) @3 l, P: v1 v5 z/ \
随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?
4 |) U: Q( J6 u" h; [$ n% d( P! m+ l' y! p5 _9 b
! L; L5 [" }% _' q. `! w9 V& Gturtles-own [ energy ]1 x# k. c$ S1 W. `- Z( |; e4 m
to setup, K1 k/ Y1 f8 ]8 p
clear-all
+ p: ^6 H+ N t+ @set-default-shape turtles "square"8 S" b" |6 A& D
crt nutrition
( w$ [1 w( O' H# a% task turtles[% z6 I! F* c5 w! `# u5 t
set color white
+ v; W7 H0 k1 U% }# v& l setxy random-pxcor random-pycor]
' I3 b4 _3 K n4 z : W! M9 e- }* ]4 E# l
ask n-of microbes-initialization patches8 y& g& z, Y3 U2 }: m% B# y
[ set pcolor green], Y' M( x L0 t3 ?
ask turtles [set energy 1]
( _) j m1 p0 k: ^3 z8 `end" h F2 v" {) D. W
$ V6 x. v- u) F) Hto go4 o+ x3 K, @! S2 j
ask turtles [set heading 90 * random 4 fd 1]
* I; z8 [" h& r2 \ ask patches with [ any? turtles-here]
5 ?+ T7 e1 p/ P/ d! Y [ if pcolor = green and random 100 < chance-of-congregating [tt ]]! D2 X, Y9 F; M
ask turtles [ if energy = 0 [die ]]7 b& [2 s- w6 F' D. X _9 M3 m9 G, \
end
" H! }: v# f. v9 B2 C: S# a
! Y+ F* l' ^* Z2 z5 d& ^5 hto tt
8 ~1 J& G1 l. w$ i) z! c" _ask patches [set pcolor gray ]
% S8 D) U$ o6 w/ Task turtles [set energy energy - 1]& \# c/ f0 H6 x7 d3 l
end Q( ]% |* \4 e) I) P
4 r4 [' b7 c- C4 h
|