请问:
0 ? S4 \ M( o4 r3 X; @; g随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢? p8 J$ r' K4 ^: T4 O5 \+ p6 x& d
8 v l% _1 V0 L6 |
3 `8 M! f( J7 q5 D9 Y. x3 A! u. j8 nturtles-own [ energy ]
- J8 d! d4 B) Y2 Q {" L' Z. fto setup
3 t8 c/ b% E! v2 _. U% p* H0 pclear-all
0 j/ {! j$ Q" T* C2 o1 G) b8 t- nset-default-shape turtles "square"9 I6 ]9 `: F- ^7 Q M7 T
crt nutrition
$ g9 g! O( B9 @; {ask turtles[
' @* E8 U" f2 L set color white
! N* E) R$ n, {/ `. Z setxy random-pxcor random-pycor]( c& g6 F ^6 Z0 X$ Q4 i$ |
/ w0 X( c( q6 \ask n-of microbes-initialization patches7 q5 D- H7 P: G! e j
[ set pcolor green]
* R0 g9 u2 x3 p* \# @6 O ask turtles [set energy 1]& X* d5 M4 s y9 w% Z; N
end
$ W6 F- P# {/ O& `9 v7 `/ U: ]' N* [- k
to go; W$ x! N4 i$ f2 S i( C
ask turtles [set heading 90 * random 4 fd 1]# c1 `" S2 {& _0 Z; w* J6 d* b
ask patches with [ any? turtles-here]4 B [" a6 ~6 m& z6 K& C
[ if pcolor = green and random 100 < chance-of-congregating [tt ]]4 ?# V6 x1 P9 P/ {' w9 u4 X
ask turtles [ if energy = 0 [die ]]+ r7 k9 K5 M/ R- F
end& s Y8 X" S O0 H4 b, ^
( n, n# O" k. a4 e" O% ?0 D
to tt
; M L) x. v+ h) H; Iask patches [set pcolor gray ]
! H: H8 M' y, b' ~ask turtles [set energy energy - 1]1 {4 b" _- x/ B
end
. J2 L( D- n6 N
+ j7 W. x M8 V |