请问:" I# l& a) ?; b9 G
随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?
& Q- g" ~: G9 n6 O# k
& @1 x3 X! l4 t
! K( W+ r% a& Y" Cturtles-own [ energy ]
$ d* F+ I9 c: f9 Xto setup [! r5 E4 K. }, S5 j; M1 b+ S
clear-all+ ^! l. w% d$ B5 O
set-default-shape turtles "square"$ c7 l* r8 z+ Q; L8 R: W! }+ q2 a! r
crt nutrition
5 ]/ m( |; N R c/ bask turtles[4 ]: b6 b4 J: T/ g
set color white
" u8 L& D* p8 f2 W1 Q3 _ setxy random-pxcor random-pycor]
8 Z) J, P6 E4 i( ]6 ~/ V" q) D9 H $ B) Y+ K" R2 \7 U9 [
ask n-of microbes-initialization patches
' c7 j% m/ d! K( m# i# S( X$ J0 | [ set pcolor green]
& J8 w6 ~! h7 u3 S( { ask turtles [set energy 1]
6 W w, m2 E( l5 U, Qend- L6 m0 x6 F, t6 ^. U+ @
6 H% x9 ?( r7 s0 ]) c, n) Lto go2 H' J, X, ]6 ^2 d
ask turtles [set heading 90 * random 4 fd 1]
5 G2 s7 D+ K; R$ {; P' o ask patches with [ any? turtles-here]0 b. e1 H" T" Z6 s( X6 u
[ if pcolor = green and random 100 < chance-of-congregating [tt ]]
; P* x8 ^3 H% R1 q' y8 I ask turtles [ if energy = 0 [die ]]
7 y9 a/ V% K6 d" y& @ end
7 R, l4 F; i1 v& m" H! G) _' A y! H9 v4 o5 B1 t, l
to tt
" X1 b# u, f/ {0 S' aask patches [set pcolor gray ]3 d' I1 f. a/ V
ask turtles [set energy energy - 1]9 Z1 E: x2 n. A6 A
end! R! Y# X# `/ v1 w1 h4 q3 Z) Z
+ T+ z$ J9 J- H/ h& \' a7 Q |