请问:% b; U2 D" z4 x
随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?4 y" H+ K: L4 |
; T& M' u. {8 c; g1 S( u/ V: e4 O, w
) _# f5 d b& L/ r6 y7 uturtles-own [ energy ]
7 s/ F* S: T& ?! qto setup* n+ G; L% P9 E4 M* ~/ @
clear-all$ c* F/ f" }* k
set-default-shape turtles "square"
' v! N! ]) X+ j. X, L9 z8 J8 S @crt nutrition/ Y6 O3 v2 z( u G1 \7 q
ask turtles[
% C1 n+ e+ ~( p" Q( K set color white
/ I# C, \1 }$ i setxy random-pxcor random-pycor]2 ?$ f8 x M+ E& T
# h; e: b" W; I1 r9 }) `ask n-of microbes-initialization patches
1 T+ q+ x |2 M1 L [ set pcolor green]/ ~/ d/ i3 y' @0 C6 m5 A* o: K5 u
ask turtles [set energy 1]
) \2 u' @: m6 Xend
( S. q- s" T5 k V& c9 f
4 a8 [( `! \3 Y- y5 Kto go( i) I- K1 H; D7 D+ C
ask turtles [set heading 90 * random 4 fd 1]
[4 Z7 O0 ^: w# p4 E% P ask patches with [ any? turtles-here]# m7 s( c, R6 }3 N
[ if pcolor = green and random 100 < chance-of-congregating [tt ]]
4 z7 i- z, H+ n. j ask turtles [ if energy = 0 [die ]]
8 X6 N! z% m5 c* M9 V L end& T# J/ ^0 l& _5 V2 m( D) L
6 C- b/ L. W) J, w: z
to tt5 S0 V, k: @7 [* w8 ]
ask patches [set pcolor gray ]
2 I4 K4 l( @9 F$ H2 K* Xask turtles [set energy energy - 1]
6 a( {& W. } g' A0 \2 o vend
6 f& T j D9 i: `$ o+ t) k2 p4 f. G0 ?$ }& i1 G H) j* Z
|