请问:) o/ @8 S7 N$ ~ w2 b! x
随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?( O: z( F% F5 K- M# S7 U- Z
# ^5 t, Z% m0 t+ L( ]2 h" w" C$ V
- j- Q5 P7 \" O+ l9 _! \: o$ Eturtles-own [ energy ]
& N: b- U( {$ Z% G" \/ b: x( ito setup
% Z7 v9 k% _6 H, o' O1 hclear-all
9 Z% G$ u& d" Uset-default-shape turtles "square"
. h; Q {' ~9 b4 q- ^" v2 f7 Vcrt nutrition
* Y! {6 v8 q$ z( @( Bask turtles[
* ]9 K* \/ v+ E5 q5 c set color white2 Q$ u, V/ w/ ?7 y
setxy random-pxcor random-pycor]
- \$ i' z t' g- g' t
, g5 z; C6 A3 V& ]1 Wask n-of microbes-initialization patches
6 V+ U. O0 K; A9 ~( |6 T% n [ set pcolor green]2 c, p; _8 T$ |2 P& E
ask turtles [set energy 1]
- N6 X9 [: @7 O( W; _) j1 R4 zend
& N+ ?2 w4 O5 a
( X" H/ d$ J( u* f5 d( |- G3 hto go
. `# T4 m8 [; w0 {- _ ask turtles [set heading 90 * random 4 fd 1]
& r4 r) D- E$ s# V ask patches with [ any? turtles-here]* w- n: P7 D8 I; v: x
[ if pcolor = green and random 100 < chance-of-congregating [tt ]]& j* _9 [1 o( d$ |7 ~0 h% o
ask turtles [ if energy = 0 [die ]]
. ? ~* V" ]1 e2 E. @ end
( L: J s- d: C- } A! `) I8 a J
to tt4 E) `) r5 Z, D9 P; K0 C; }% y
ask patches [set pcolor gray ]$ `1 R" J, d# _$ B+ j, y# J
ask turtles [set energy energy - 1]. ?4 A3 d( I& ?* R9 v9 N
end
9 K( L' O: u1 i! o. h" }8 c2 G8 E! T1 a% i- ~0 _- `( d
|