请问:
[% _# }; y! T( k3 k随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?. J8 B, W' t" J: s* Q
5 |1 L! f/ d7 X, X
5 O/ t) i4 J2 n0 b* Vturtles-own [ energy ]7 E. |7 ^- p" I
to setup
2 A9 V: G3 I5 Q8 E, ]' }5 D/ aclear-all
9 F% B6 q( s% }: _& L% L3 wset-default-shape turtles "square"
1 |, ~9 }* ~: v' e. O$ V- O) l- u7 mcrt nutrition/ {" m3 x7 }! _+ l* w: r
ask turtles[* U8 j: ]* y3 Z! ~# T
set color white
0 o$ Q* `+ e7 u6 c setxy random-pxcor random-pycor]% _" ^' K& d8 x. S/ \3 r4 x* f
) J B4 \, Z0 mask n-of microbes-initialization patches1 F/ b) Z' }& n; g( d& v
[ set pcolor green]
0 x, e% C$ p: I6 t+ ^ ask turtles [set energy 1], j+ z. B* A# @0 W
end
9 k. c% D0 G. l6 I# f4 d- U$ n$ X: `6 i, n' M9 O; ?: `7 m
to go
. w4 z/ q1 y$ a3 u# J ask turtles [set heading 90 * random 4 fd 1]. D' F. Z3 |; U$ u
ask patches with [ any? turtles-here]/ N5 N, c6 b" s2 A* Z
[ if pcolor = green and random 100 < chance-of-congregating [tt ]]
- x( c- f/ B8 N( [* h" N" I ask turtles [ if energy = 0 [die ]]8 Y( `+ P; v7 c
end
. Y# K1 K _: u; R A2 F* U6 g G
L+ |; \& Y3 g3 s6 c% x' Bto tt2 w0 g) M& ~. s4 o8 ?2 w
ask patches [set pcolor gray ]5 [( J) C7 I$ {' X; }& ?
ask turtles [set energy energy - 1]
. T9 \2 F9 A* g- U# [end) I) [" K7 U8 c5 F! l) ?( E
& A' F2 Q" E' @2 A; s! d; I |