请问:* E+ P5 v' k/ m: @9 z, d
随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢? E, C) ]2 B5 H* M4 _' H/ E
/ g: ~' m3 ]7 G! M X2 B8 V3 |
p3 @6 A/ P& C& G# Dturtles-own [ energy ]
3 X# @* S1 V2 H' p, Y, V- wto setup
" b ^) J- A5 C( T& w: oclear-all
/ B+ w X& Z) yset-default-shape turtles "square"% G8 x0 K9 k7 ~
crt nutrition8 l2 ~. \8 f4 a: T" C
ask turtles[6 A# P( O( {% I- \+ l# T+ Q7 q" A& F& m
set color white
. U3 I6 q" o! O0 v3 ~, |/ c& _) v2 o setxy random-pxcor random-pycor]
" p6 Q: D9 ~/ K i/ c" c$ P4 m , c" m r8 ^, a3 B% @
ask n-of microbes-initialization patches$ G+ E# ?. r* K x3 {( T! M1 m
[ set pcolor green]
; n! R5 h; V" |1 S& B! y" L ask turtles [set energy 1]
, ]5 `& h) K5 m& aend
) g3 k) i# P: g) Z/ X3 {/ } G: V) S$ J( G" C6 ^, D, J9 n
to go) }/ B, X& B9 c2 g2 X" Z
ask turtles [set heading 90 * random 4 fd 1]0 v0 t- b" e8 X6 L3 H8 i; k# l2 o
ask patches with [ any? turtles-here]
! r3 b$ t( m' g% g; h6 ~# e [ if pcolor = green and random 100 < chance-of-congregating [tt ]]# \7 `- Y# ^/ Q% e
ask turtles [ if energy = 0 [die ]]. Y1 ?" \; i7 Y& i; Z; Y
end8 L* L, \1 s: K
! I+ Y& l" Q$ {# Kto tt
) N5 t1 `: j0 t' c( y- |ask patches [set pcolor gray ]8 N# a, ]( n" K$ f; s& m
ask turtles [set energy energy - 1]3 e& j0 I7 ^9 ^$ C8 s! C2 t
end
8 y( K6 q! _: d0 \( r2 O- G W) P" u7 q
|