请问:+ i( {! o4 J+ Q1 N3 R1 a
随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?
/ ]; E2 E7 j5 z2 I/ D5 H( e- l' S
: j: X2 o9 e* M8 V! ~
6 o; R' y5 K' u- X+ p! F4 G9 _, {( eturtles-own [ energy ] e" E5 @/ {/ K2 [" R
to setup
; s- k b' ]8 t# K0 G0 a3 Tclear-all
- U0 u( W, O9 t8 u9 zset-default-shape turtles "square"; i# j0 [( [6 P8 j
crt nutrition
8 N/ \+ s7 A7 }/ s; d4 aask turtles[; g* l4 A+ O4 ?$ S8 S: l
set color white
2 p- S C% S+ e8 o; z setxy random-pxcor random-pycor]/ I5 g0 q4 x8 \' \2 t* D# E
p$ G, K* [7 b' Z3 Qask n-of microbes-initialization patches
]% G! s8 @3 W. ~6 u [ set pcolor green]
; q) h- R% @5 ^+ D8 B ask turtles [set energy 1]
# O" l0 t! P- q* O& a9 Q; `end
2 o7 W) @1 `, ]) J* W5 k0 P4 e0 t3 i5 Q R3 `
to go
, M4 O ?: D# h! w2 Y; U6 z. S- D ask turtles [set heading 90 * random 4 fd 1]
r1 Y% x+ K/ p4 Y1 a( A9 m ask patches with [ any? turtles-here]
' ~4 o& [& e9 p; D* u [ if pcolor = green and random 100 < chance-of-congregating [tt ]]
2 B3 x$ m: ?6 |) h! K- d ask turtles [ if energy = 0 [die ]]
0 ~/ K5 k9 t* m4 N4 ^ end
* Z1 B8 e x- W8 d" v: E! {3 f# A7 q- R
to tt( `+ z9 c0 ^, n$ W
ask patches [set pcolor gray ]7 c3 c- A4 P1 `6 q* R
ask turtles [set energy energy - 1]; S6 L+ m) F8 B, G
end; B$ d* [7 Q3 d
7 z2 X0 p/ o! ^7 n. G m
|