请问:7 v+ q( C2 e5 r
随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?
" Y D$ u& R( e/ Y6 n1 ]" F6 U- D( R; K6 @: ^! c' U
5 K- m# n3 R; \" c" Fturtles-own [ energy ]
$ B1 ]" a f, B2 ?to setup, w7 }$ I" H, q$ b M$ X/ B
clear-all+ z2 N7 \! C/ ^! S6 `; ?
set-default-shape turtles "square"
+ E( ^6 w" D8 Vcrt nutrition
6 i( [: z/ J$ k/ T" Gask turtles[
9 N/ Z v0 G8 {) S6 z set color white9 I$ |0 c* |/ F5 `, w
setxy random-pxcor random-pycor]
% t- [ ]( ^8 Q 4 s7 a& M# `7 c8 V
ask n-of microbes-initialization patches
! M. J2 N! G" a. T- e! \5 L [ set pcolor green]
' t* E5 @! k0 r, a, |$ O ask turtles [set energy 1]
+ r$ d! k0 F1 c- p! ]+ Y! [0 N2 ?end; u1 x' F/ ]. k' m5 f# x' P
& l7 i7 I; T" I4 Jto go# B U0 O9 _" e7 R* I% A
ask turtles [set heading 90 * random 4 fd 1]" M) o' k6 f* _- ~& Q
ask patches with [ any? turtles-here]
& c7 [/ s, |4 T9 P) M' [ [ if pcolor = green and random 100 < chance-of-congregating [tt ]]6 Y& K6 V& r: D. g0 ]
ask turtles [ if energy = 0 [die ]]: R) U- H2 R! H, I$ \) ?
end( T9 _0 }) C$ q& g
1 h5 H9 Q0 g- v4 fto tt
5 Q9 ]; T0 r3 ]' `& jask patches [set pcolor gray ]6 }, e; l" ?3 Q3 Y, {3 |$ z
ask turtles [set energy energy - 1]
8 c p0 P9 d6 {4 I' |end, C2 d% _0 h8 ~8 s" R: t
* _* D6 P* W7 G, v, i) Q
|