请问:
$ B/ W5 j2 ]( U' E4 U) y: H随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?
8 J: ]: q/ v( M$ a! N3 j' m; }7 |% g
. Y! T7 |$ D4 h( G0 a9 h* R
turtles-own [ energy ]4 N( \$ l$ M- e; p% w
to setup
1 \+ e( w8 `& o, @3 Xclear-all
. U3 w: e5 r% W9 H8 ~1 f9 h9 ?0 Dset-default-shape turtles "square"& {9 g: k5 `% m: R
crt nutrition% O4 b; t' K! e* S2 i' o
ask turtles[
/ f" q( i+ d. ~3 [2 Y set color white
! Z7 N6 d) O: ?6 b) ^ r setxy random-pxcor random-pycor]
% Z& L; D- a/ S % e% U8 Q, y: `6 `: Y: `6 W9 l" x6 I
ask n-of microbes-initialization patches; F% o, ~5 l% k& J( W2 F3 i
[ set pcolor green]
6 b0 C9 |- @2 o/ [) [4 d# `' \ ask turtles [set energy 1]7 j& E" Y% ^! g
end. T/ \$ F; Z7 ]3 `& A* N5 _
. O3 W) v0 C% @to go
% f c% Z7 s% q! O8 t ask turtles [set heading 90 * random 4 fd 1]
# F+ {! j- u- `* i% \ ask patches with [ any? turtles-here]
( K( {1 K) o( M0 B [ if pcolor = green and random 100 < chance-of-congregating [tt ]]) T9 B0 _% r7 L$ E) R' U2 T
ask turtles [ if energy = 0 [die ]]
; f$ w( W( W9 k1 ~. y6 S/ r end- p6 l1 N6 I6 \' X8 N
4 G8 X' N1 D1 B/ i- F3 I, M
to tt1 L5 g, c( L) T' S0 |9 H
ask patches [set pcolor gray ]+ N8 b W% _, N5 H
ask turtles [set energy energy - 1]3 G( B6 n5 }: [# _; }) e
end) O3 v/ O o; W- o. `: ]
% i& r, Q! R; m2 t2 M5 V: c |