请问:8 K& M0 T! ?. e: v+ p" j
随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?
: Z1 S5 x1 c; m. B
4 ?; T; \& }' l! ` O6 r1 A" ^! [0 y- e4 q1 U
turtles-own [ energy ]
* L/ {9 h+ D5 L7 ^' l, Hto setup
# c% k; g* W# F( Zclear-all. ] b. |2 G1 M Q2 p
set-default-shape turtles "square"+ g o/ I% e1 i6 f, p; G. Y
crt nutrition
* y Q8 z j5 {! P6 v- fask turtles[
' x/ T. ?: J9 s$ G3 r6 X7 M+ [6 z set color white5 L6 v) |( u8 \, Y- q; G7 a: `3 x
setxy random-pxcor random-pycor]' l. o/ s! v7 Y# y
2 d: u1 V$ a2 i" rask n-of microbes-initialization patches' \. v9 i0 `( j9 w% h
[ set pcolor green]
7 C+ @1 G6 n# a ask turtles [set energy 1]0 w6 a" u( W* E* e( n9 M6 h
end. S3 N, t/ ?" k V
# `( Z/ m9 T6 ]7 M6 a5 e
to go
. B$ K3 A* |! s, r) L# h8 B ask turtles [set heading 90 * random 4 fd 1]9 t5 H) N# \" x
ask patches with [ any? turtles-here]
; r" W# E8 q2 E1 T, D% q+ T; N& P( e [ if pcolor = green and random 100 < chance-of-congregating [tt ]]
, ?: a! {- g: `& P ask turtles [ if energy = 0 [die ]]- e8 f0 ?) }/ L* h+ M$ P9 A
end
( s* t; D# H4 u8 C( x& P7 f: z7 Y3 ~# u2 a
to tt( n1 J( B; Z, Y0 `* ]( d
ask patches [set pcolor gray ]9 Y0 P2 g+ q ~6 q1 p# i. M6 @
ask turtles [set energy energy - 1]" ~ o' A; }( ~0 F2 e! {
end
% f( S/ r3 k6 Q: `! b
: `/ @7 J0 Z) J. K |