请问:& m. C8 j5 B% u J
随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?
. a C( d2 x2 x& v# u+ U; p$ t% \" l: x& v
% x/ I6 e9 ]6 F4 u! L/ nturtles-own [ energy ]
* @) e2 ^- n9 U" z, L' n- yto setup; W7 h# k# l: S. U
clear-all
; \! h. g; x. Jset-default-shape turtles "square"
) }8 z$ p5 Q" ccrt nutrition5 |1 e1 P, R, i
ask turtles[
O- [& M' B3 _. x, L- | set color white$ c `1 z3 d9 i+ f, D
setxy random-pxcor random-pycor]
. ^- |; S, M6 w& S( y& K 2 ]* c. N! T) Q' Q$ F0 O
ask n-of microbes-initialization patches
1 f* Z6 B% q* e" Z" ^ [ set pcolor green]* ]; O6 r7 ?7 A% w
ask turtles [set energy 1] X# G# y( v( T, d) o
end
. t, W: M7 k) j( J
0 z/ f5 e: {; Y2 Q& Jto go; P4 D1 ^% x' P; i& h/ ]/ d/ ]
ask turtles [set heading 90 * random 4 fd 1]5 P8 G" Z C( G
ask patches with [ any? turtles-here]
) C* c) T* h9 P& @8 M5 T [ if pcolor = green and random 100 < chance-of-congregating [tt ]]
: w( S X- }; _/ a/ x7 R; \ ask turtles [ if energy = 0 [die ]]8 e( r) P$ \0 {0 v: a
end4 q2 V) ~7 Y+ ^+ Y$ n
9 t9 z4 ~0 c- Y$ [, [/ Q
to tt) i# u/ z5 B+ Q! j2 Q0 e) { t
ask patches [set pcolor gray ]" `# i/ b! z+ V7 Z6 P
ask turtles [set energy energy - 1]
/ p" z1 b5 u$ {, U- }1 ^0 T0 hend
; h: _9 R# ]4 F6 o
& ?! X4 d# I( z, `5 a2 k |