请问:
5 R4 y- C, q7 ~) X# t9 S& q" G* K随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?, Y& i/ H7 c S0 R0 l
$ c* J; r& c+ c, F% B- M
- ~8 o9 n+ R- ^turtles-own [ energy ]* \2 h- z6 U/ N
to setup
5 u. ]" v, P3 b, N" {. c# U1 ?" Iclear-all- U/ x H, O+ A. y$ |1 a- i
set-default-shape turtles "square"
5 S' t* p) p( @5 z" ]crt nutrition" J1 b, [0 k( s, |9 |; s) M
ask turtles[2 O- D6 j7 t+ \9 l6 s3 O [
set color white- |6 M* ^! P0 U* Q$ Q$ j
setxy random-pxcor random-pycor]
$ n& F5 ?2 T. p; N% @
2 w5 [6 k% r6 V% ^- Cask n-of microbes-initialization patches
0 Q; [: M+ S! ]: ] [ set pcolor green]
7 w" Q+ x6 {3 Z ask turtles [set energy 1]7 K5 G8 ]0 |3 z/ m6 M4 E
end
' V! ^) [; I# B( e' }" v4 a, n' D+ F
to go
% e4 X6 Z+ C% M* `$ ~+ l; z1 L' c ask turtles [set heading 90 * random 4 fd 1]
' \3 ^5 q- I3 }- g ask patches with [ any? turtles-here]
# I' w4 z1 a% k6 \) Z' ~' C [ if pcolor = green and random 100 < chance-of-congregating [tt ]]
& H4 ]7 V" R8 T' `7 r3 b ask turtles [ if energy = 0 [die ]]
) G' z, b0 E+ K! u end
$ R- t5 d; Y# K; j6 I
, Y% N" J+ l" C7 @to tt# o2 g' F; P% g( f
ask patches [set pcolor gray ]3 P4 m8 s+ e' x) {7 u# y' Y
ask turtles [set energy energy - 1]
% g3 o" T( ^& D _end
, O, r6 y; @: }; G7 _$ h4 M$ I+ R- d
|