请问:
3 ]( U$ `' ~5 ~+ X' K随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?
& T+ }& B+ X9 L2 q/ n- i8 Z& Q' s6 D
0 S: \' P. M# |+ P3 kturtles-own [ energy ]+ g; a% `, v) D( B! l* {; K. _5 ~
to setup
& S2 F" Y+ g& j+ Tclear-all
) l+ n4 _6 w1 Q2 T1 o8 u! d3 d6 ^set-default-shape turtles "square"
6 P$ a8 j: n. e, Icrt nutrition
" ~6 r ]3 d0 Q8 h6 a$ W3 O4 hask turtles[
( F+ F. |' F- I* v8 R& {" F set color white4 ` `# T4 Y% v* H5 p
setxy random-pxcor random-pycor]
# j% l% Q( U; o6 a" d2 o# f$ {/ W
' Y6 U7 D2 y1 C7 K- gask n-of microbes-initialization patches
- `! p; U8 l; f [ set pcolor green]
# r3 B8 G1 c4 v: O5 G/ l ask turtles [set energy 1]' @, z2 O0 z# B- K
end
, d' f0 t& D; r
& p3 j# i: @5 G, y! s: Z6 n8 Oto go
; J+ w R, p4 O ask turtles [set heading 90 * random 4 fd 1]0 J) n, _" a& m
ask patches with [ any? turtles-here]& V& U! H/ }( \+ k
[ if pcolor = green and random 100 < chance-of-congregating [tt ]]
6 [. W: P# |7 a5 `4 T9 N ask turtles [ if energy = 0 [die ]]; b$ |7 l3 Q' j
end* u2 V6 J- p4 j3 r
\% d8 K5 i/ E/ S' |* V$ tto tt
/ w8 O, J% T! A* ]2 S4 M, u" A6 ^ask patches [set pcolor gray ]1 m3 c/ v( Y# T% N# ~
ask turtles [set energy energy - 1]
7 q+ {* F4 [4 l" ^& U: Zend' m" U. A) ^% H( T# S
4 p' V! H* F$ x7 [2 W$ [8 ]: b |