请问: T2 B; g' ?. I( E
随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?
1 [" i) d' q: H9 u2 R
7 ^/ l0 G6 q0 Y6 N
4 c0 o! y5 j: K) Oturtles-own [ energy ]
2 R0 [+ e, E3 G {, [to setup
u8 |5 X; n2 L- U3 ^ rclear-all" d! y3 @2 F3 i2 W5 C
set-default-shape turtles "square": @( ?6 `" |8 @4 i' b! s5 M- G& p
crt nutrition% Q! _: {- d' ?9 g, D3 ^
ask turtles[/ b5 E$ _! C$ d4 V/ e M5 c/ X; X! U
set color white
3 h/ D% ]$ g5 q2 F- t) M$ ] setxy random-pxcor random-pycor]2 _, d* P. d: x. V7 Q
x: h3 c! `% u5 v$ ?ask n-of microbes-initialization patches
& \% L6 @% u: }; J8 ^ A. D9 i& Y [ set pcolor green]2 M+ b( J" @; F9 E& j! y ~
ask turtles [set energy 1]: h: }# q0 K- X, g8 ?3 Z
end9 s- z: {3 n0 _) C, Z
4 N# W6 d+ W/ y# W6 k
to go
8 v, _1 F- t$ X; N; N/ A ask turtles [set heading 90 * random 4 fd 1]
6 r. W+ \5 o9 k! F# F8 w; p" O( | ask patches with [ any? turtles-here]
; [! H6 ^2 `. u S: R0 c [ if pcolor = green and random 100 < chance-of-congregating [tt ]]
8 I) R u& X/ } ask turtles [ if energy = 0 [die ]]2 [6 a7 V5 ], l
end# W- T; r9 {1 B+ X3 z
' R# c. T5 o s- b4 Q* Z" tto tt, q$ ^3 T: Z/ X. } o; M
ask patches [set pcolor gray ]
4 q! l( u6 l$ xask turtles [set energy energy - 1]
7 U9 q" D( r- P) _5 }- |end
) `+ T: |' Q6 O9 s, J8 g( b/ N* z$ T8 P5 P4 |3 v0 D/ o9 u
|