请问:
( U5 \6 e7 k+ M随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?
( y( `+ r7 ]: [) O8 m! B+ c& n2 G. G' j) t' ]
5 }/ q) Q& x2 T) a
turtles-own [ energy ]- o, i: `9 Q5 Z9 \: I
to setup
u1 L+ \6 y6 Z/ `* B" `clear-all
. o/ `4 I& \( Y/ k$ W2 |: T$ o5 ?set-default-shape turtles "square"1 n3 ^' W _% W, p
crt nutrition
; P$ s7 f( A/ Gask turtles[
6 W; F! F( T: J3 Z7 b set color white
, Y2 P& K& R1 G: y2 Z" K setxy random-pxcor random-pycor]5 y& I: X+ t- R( M+ m
( S5 c# [' s) m" Z- o4 N1 K3 B
ask n-of microbes-initialization patches0 G- M. [. G9 F7 a; s0 j
[ set pcolor green]* c" s' J( w2 M" A. L
ask turtles [set energy 1]
* U9 B5 Q s) d) vend
1 j9 ~5 ~) q1 a, p6 |) x+ M4 h! T4 N
to go/ v- g$ H& m" t3 e
ask turtles [set heading 90 * random 4 fd 1]
: w5 z: ~0 u) Z9 E& P J1 e ask patches with [ any? turtles-here]
2 y6 S6 D5 N5 @2 V. z [ if pcolor = green and random 100 < chance-of-congregating [tt ]]
% J2 z, S1 E3 U7 _4 {* `6 ? @- N ask turtles [ if energy = 0 [die ]]
% M% `1 b4 Q( t* M2 p& y end( k% F5 F' L3 y2 I: B3 w
+ x( {8 v5 j$ R2 O! _; \to tt
) p; S/ H0 l1 j9 k' C* hask patches [set pcolor gray ]4 }# y% W* Z! j3 E m) M
ask turtles [set energy energy - 1]/ [8 [/ A& O) [ M( {- P
end
. F; f0 R' e# n% y1 k3 A$ Z* }- r9 N- S8 _
|