请问:1 t. {: ]2 z% B' X" _
随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?; y, l) a5 ~; I. Z N8 S: {2 {
0 q- ?: R4 t% N, I# k
y% E3 t- }& Uturtles-own [ energy ]
$ } U# J% @; E# p2 H/ Gto setup0 x4 ~1 A( d! f' B+ e; J: D/ j
clear-all& w: D8 N4 K) b" V/ @
set-default-shape turtles "square"
$ a$ ~/ P& x. `& ^! d' ?6 dcrt nutrition
5 k9 O; N; {/ }6 P" c# B( f- rask turtles[
" w+ g( |& O9 H/ d% L# T6 w/ O& J set color white1 H/ Z% r b* o( n \/ e
setxy random-pxcor random-pycor]- W S% {6 B5 p5 q
8 M+ T* i' r0 J. bask n-of microbes-initialization patches
! v5 ~6 s# N0 M {% V1 J& Y [ set pcolor green]
" C7 n( A* K( Z ask turtles [set energy 1]5 ~2 N: j2 \0 \
end
/ e) d" ~# X. m% _3 |& L5 z4 [: f; q3 H r9 T) y
to go
7 ]# [ n1 `" m ask turtles [set heading 90 * random 4 fd 1]" Z0 y1 `, E7 ?9 y! v6 e" V7 n
ask patches with [ any? turtles-here]: G( W0 V7 V* L% ]; }/ V- S' f) K
[ if pcolor = green and random 100 < chance-of-congregating [tt ]]! v' n/ ~+ s- q) f7 D" v8 I" g8 a& \
ask turtles [ if energy = 0 [die ]], X4 s5 d+ \, L4 F7 @
end1 m, G7 F, P! U! @ y7 h4 m
4 ]3 }4 ?6 g* g$ E+ k) [
to tt
! Y" y2 w! {0 R! M3 u8 B$ y, uask patches [set pcolor gray ]) ?. f. ]# L/ ^
ask turtles [set energy energy - 1]3 j0 D, c& {& c, t9 S* L
end
. K7 D# ~0 D/ C. h$ {" z
9 w8 a& J) `* h+ l; s |