请问:
. u$ n( U3 U2 m随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?
, `4 y4 k+ ?0 i' I! u1 E: ?8 K- L9 u5 c s W2 d6 J& O6 B4 s
8 V8 L% O6 e7 `: ?turtles-own [ energy ], ^. d' t' O. A9 S3 Y
to setup/ {. B$ s# T5 }7 x3 ^* a
clear-all
( J9 a( ^3 P& [9 u- eset-default-shape turtles "square"" U% w' z5 p) ~7 T9 X7 u
crt nutrition
+ I5 Q4 k/ N4 K# ~6 w) K c6 eask turtles[1 k5 G" u+ M! u0 x& F! n( M
set color white. P/ u# \& y M5 H
setxy random-pxcor random-pycor]! L( @1 H8 K. n/ L0 [, E
X: {( E0 {. c2 Kask n-of microbes-initialization patches
8 q6 N( p5 p1 P- C) F [ set pcolor green]
4 e" Q |5 ^. Y: X8 D/ P ask turtles [set energy 1]
, T9 ?, o% Q2 s2 {) E' b5 `) Uend
5 U- b2 a. C' M$ m7 B7 r4 p) X
! a6 T5 s+ {! E# U) i6 S1 i( \. E; fto go$ Y" e, n$ X1 v F5 I) s& S/ c
ask turtles [set heading 90 * random 4 fd 1]* N! p. I+ L% z3 s; U1 Y
ask patches with [ any? turtles-here]
; E- K3 w+ E7 f* K( w( [ _) Z [ if pcolor = green and random 100 < chance-of-congregating [tt ]]
% t7 v1 A8 m0 C0 U ask turtles [ if energy = 0 [die ]]$ K7 Q; c1 y& c0 d* m* g1 Q
end
$ N( m* K: [; f$ s9 `
$ T L6 d5 \ z# Y+ R. {) ~to tt/ o! H% j! ^; d0 u) U ?
ask patches [set pcolor gray ]3 L2 X! s. i3 A2 n0 ?2 X; K
ask turtles [set energy energy - 1]
S3 y0 S8 Y( C$ W0 K5 R8 u$ qend
$ Z. a# U# R" J- H" _) \8 L4 z I1 f+ ^* z, Q# I+ T, L% w
|