请问:, E' n7 i) u; m9 o
随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?& R$ e+ y6 y: h/ I ?3 l
4 f* m5 `% G" ^! D6 a0 b
3 N: J5 ]+ }" Eturtles-own [ energy ]
1 Z% n. ^8 _# P/ Wto setup
: @5 e+ e; X3 `1 E& p8 vclear-all
8 e8 [0 n6 w6 _1 }' hset-default-shape turtles "square"9 k1 h8 l+ N$ Y# _3 R4 J
crt nutrition P7 A$ o6 F' O7 X; ~. u4 ~
ask turtles[* x/ t2 O7 _5 m8 \, Y0 d% W
set color white+ J4 P+ j2 n' C/ c3 u. u
setxy random-pxcor random-pycor]
7 O6 m6 Z6 d; [' l, S
, @2 P) l& i' sask n-of microbes-initialization patches/ ?5 L# h- v5 o7 P' U' K
[ set pcolor green]
, { k9 [7 ]0 Y# g- }8 |- C ask turtles [set energy 1]
0 u, E7 k' S; I" m# Xend b K2 l |3 w' B9 [# ^. a7 M
4 B/ h* u. [/ V j, `. G( f$ K
to go! g T4 ?' B6 c! f5 V% S
ask turtles [set heading 90 * random 4 fd 1]
/ X5 T. t. B) E$ ~* S ask patches with [ any? turtles-here], `% w# Y; i* M6 d
[ if pcolor = green and random 100 < chance-of-congregating [tt ]] O, U8 u! y$ D8 s% h& J
ask turtles [ if energy = 0 [die ]]
~/ E' L4 }7 t1 C5 X9 x end0 z; ^ ^: ]4 Q; l M0 Z' ~
; q" G$ g" p& N6 d6 `& O n
to tt
. u& Y$ `2 v0 `0 [ Xask patches [set pcolor gray ]
. C: G) C6 V( h% s8 vask turtles [set energy energy - 1]% e( b4 U+ H0 v9 ~9 W
end
8 P# e. w( O! i6 W$ f2 B% G# S) t( _
|