请问:
! [0 B( d( d* G. b8 r( ]随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?
' _4 O& T& V, \( \2 ~0 C. j2 ]5 d/ v2 A( q' o
6 w6 Y2 W) I: w( S8 H3 \3 Pturtles-own [ energy ]
9 Z1 ~3 [' y$ s( F; c( dto setup' n" n4 m2 u/ B
clear-all
2 B) M4 w e2 g3 A- i% ^2 Tset-default-shape turtles "square"
# a2 ~5 w1 ]# L5 w0 acrt nutrition
8 ^3 [: L$ y4 h# W0 S% Eask turtles[
! J" Y2 k9 \+ J( a2 S set color white
5 e* K8 r2 P7 Z* l; r; C4 I: W setxy random-pxcor random-pycor]
: W, m5 T% K2 e
0 O3 @% Q% Z8 Aask n-of microbes-initialization patches
. T. }6 D3 `! E: J [ set pcolor green]) F% E7 s: R h$ V" R
ask turtles [set energy 1]' v8 f2 N8 T2 x9 ]3 L2 T
end
7 @- r, c( e/ N- g
$ x% y# T7 _6 f! c7 _% a! h- u9 Kto go
4 Q# N8 v5 p9 ~* k ask turtles [set heading 90 * random 4 fd 1]( S9 h K# M2 @% G, t6 m
ask patches with [ any? turtles-here]& W1 x0 o9 H) s+ ]
[ if pcolor = green and random 100 < chance-of-congregating [tt ]]
0 g t8 G& p$ ]! S$ [2 x( { ask turtles [ if energy = 0 [die ]]2 p* H' |( ^! R% u4 j' C
end" c% F) ?- U( Q% [+ T
" V5 o+ f* O$ ^$ i+ X
to tt$ x/ o0 N+ J& S
ask patches [set pcolor gray ]" q. H4 V* P9 |
ask turtles [set energy energy - 1]- r& |; v6 S$ [; @
end* S/ j" h9 a; s" D, n$ s- M
/ w7 V7 n! y- ?1 d/ W |