请问:
( a( k0 j B; |, {* j随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?3 X- t6 F8 h V- l% n
! O' @# e) R- j. O% x
9 n- u# U9 ]3 b/ Hturtles-own [ energy ]+ f) O1 O1 B) c0 s0 @) j
to setup
% O. m0 g' j. S. n7 a& y& [2 ~0 ]clear-all% E& h$ b6 k4 t7 E- ]# o
set-default-shape turtles "square"; M" k! q/ c+ m5 S: W G. y
crt nutrition7 M8 W" h4 O: w- O
ask turtles[. Q8 d# B8 {) D: ~
set color white
, N& f, E, o i; A setxy random-pxcor random-pycor]
, I! b. T0 T8 V( N
9 I% O3 h3 k$ u9 m& M7 S, W, Rask n-of microbes-initialization patches
, z; A* m+ p7 q% ]; ^: z [ set pcolor green]
! l+ j v0 R" `) s! m3 v" u ask turtles [set energy 1], d- R: h0 w6 Y v8 ~
end
0 H+ H( V8 f% ]* h2 p
/ { p0 g# t2 h( T4 O; i4 J, p: qto go
: E5 Z2 G- Q1 G- m ask turtles [set heading 90 * random 4 fd 1]
2 F) J) z' a; x) \' P) u: K3 b2 g# o ask patches with [ any? turtles-here]
6 N1 R' i% Y, \- _; C* z% D( ~ [ if pcolor = green and random 100 < chance-of-congregating [tt ]]
5 p/ f" b; R. T5 |$ g ask turtles [ if energy = 0 [die ]]% J' W4 A f. J( F; P
end
. g( v8 v0 h5 y
: r, O2 ?) g6 h0 a& K% {to tt
" _& C) G) M9 g5 ]9 l1 d Sask patches [set pcolor gray ]
& ?# P/ C$ C, n! V+ [ask turtles [set energy energy - 1]' p4 V( F) P, p; r* d: F
end0 u5 k; q; B4 F+ r" B
9 d4 n! @4 n% j# V' X |