请问:6 ]% k% Q, w* Z
随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?+ c, J: X; U' B$ l% X0 x: l
$ L4 n# |& P9 F& O v
7 _3 W% {; Z" J4 s
turtles-own [ energy ]
/ G1 b7 x/ {3 e5 K; e. R9 dto setup
+ v$ {6 p2 e6 \clear-all
/ r; x* A& I; D( M& f0 l* kset-default-shape turtles "square"7 V. ^6 v# @ z( M& v" L3 J
crt nutrition! X1 I3 v4 ?/ F7 J4 E# X& s
ask turtles[
9 Y" b+ x8 y! E9 o8 S7 c8 n set color white0 v" L' z2 L, J6 T7 y) g7 P# _; e
setxy random-pxcor random-pycor]
% l, a/ v# t* S7 A( I; |+ E3 M" |0 f
6 d% V4 X, ?) ]$ p% l0 Qask n-of microbes-initialization patches0 j$ a- ?' R" u- q9 b; x2 |7 ?
[ set pcolor green]; @. X/ e) \" _3 p9 T q3 r) q' D4 C
ask turtles [set energy 1]
! y( N0 ~7 H1 }" `6 a& }8 Q p3 A. {end
; i% b. J* A# ^+ X; y5 B8 E2 @1 ~$ g# A
to go
' B, _, i1 k# |1 t/ B7 d ask turtles [set heading 90 * random 4 fd 1]
; [+ I, H$ N3 M' m ask patches with [ any? turtles-here]2 M) B- h5 u! F% g3 b
[ if pcolor = green and random 100 < chance-of-congregating [tt ]]
0 e9 j! O; l# [8 M: N2 Y. f) P ask turtles [ if energy = 0 [die ]]) P |4 s" O' J; C! u2 j; t4 `' g; Q
end
, S- N5 i# S, n* E9 ~ f& Q5 l4 T: j9 f& T0 y
to tt8 R3 u, T2 R. J b
ask patches [set pcolor gray ]- y2 n/ @. a. C( N. t# [
ask turtles [set energy energy - 1]
: A) n8 h: _) m0 d; }+ C; Pend
7 a5 l+ K& P' ~. G, S4 P: e% b- Y0 @1 w
|