请问:
8 E2 S7 A& k$ w, t, F随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢? S! ^5 e& u0 Y% B4 l9 P2 ]# _
& h. `' ^2 B" j$ v A. g2 b 4 z& W7 Q5 e( B, i
turtles-own [ energy ]8 j. n# l% W4 A
to setup- E% X7 b4 b* U2 B0 ]# T- K
clear-all: O' N' {" i) y' B
set-default-shape turtles "square"" j( d' F1 x! T5 b9 E" Q
crt nutrition/ W& ]) N* b3 N
ask turtles[
; ]) ~: x# B7 M" u set color white# ~ b8 j* I( c3 u& r# Q
setxy random-pxcor random-pycor]
* ?9 a+ y) p+ z; z9 I" h
: o* s1 d% I6 ~0 q4 cask n-of microbes-initialization patches: d9 k( U# d, n
[ set pcolor green]
5 P/ _6 _. B; y( p ask turtles [set energy 1]
# z6 Q3 }" L% b; V6 x5 u# A. U! Send$ w# t5 [5 s: r6 T# B( t
8 e! }" }# C& O; pto go3 x, ] s T2 r: K4 b' j. k
ask turtles [set heading 90 * random 4 fd 1]$ w2 k; R1 c. y& e1 J k7 z
ask patches with [ any? turtles-here]
7 h* {4 d2 B( {3 R/ H; x% m) [ [ if pcolor = green and random 100 < chance-of-congregating [tt ]]
* ?8 b: |3 K, g ask turtles [ if energy = 0 [die ]]
) U* `; o: y/ U" V8 k( n8 ~ end R4 j" y6 K3 U& ?. `
6 O0 I: R! h, w; Z" Z6 j! cto tt# T/ O7 \( P* \. g" g- J( \& G6 i
ask patches [set pcolor gray ]# P$ b' Z @& G$ y- }% ~2 h* T
ask turtles [set energy energy - 1]3 f! B- u8 e/ b# M* t q
end
0 R4 o+ }& N( e" Z* h( X0 z+ R7 \+ [' I
|