请问:& l9 M, f& x, ~, s) T0 d
随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?
* C' K4 J& G0 g2 {' n- B. c% t! n3 S: \
! u0 M7 c7 i7 z
turtles-own [ energy ]1 G: J+ W& K+ T& `
to setup
w: n/ E. [% R _ A! Dclear-all
+ c. i, W2 B `0 y% Dset-default-shape turtles "square"( F8 N4 Z ?2 d; ~8 |
crt nutrition
9 N+ _, X$ d# C2 `, }1 k& Task turtles[% q6 y* ?* q: r* Q" _
set color white
: ]% J6 G5 @. G ?8 o1 j k+ I setxy random-pxcor random-pycor]
- ]8 h0 e0 _$ S5 @
9 j! z; _1 Z6 i1 C- Wask n-of microbes-initialization patches
: N' s9 y8 a3 a3 r6 ?! Y [ set pcolor green]7 [0 [5 w4 \: D
ask turtles [set energy 1]
" q* |, n: }% [, a. Vend
7 I& O; @+ _9 N" b- y
8 _) Y0 L' j- fto go
$ k1 ^& }$ ^. w; q/ H: ^ ask turtles [set heading 90 * random 4 fd 1]9 j% }7 x6 J: p- j
ask patches with [ any? turtles-here]
. ` i. |+ ]$ G( I! h& g: m [ if pcolor = green and random 100 < chance-of-congregating [tt ]]
7 |8 j4 S$ Q' L' y& O ask turtles [ if energy = 0 [die ]]
' D5 m, h6 o7 ]5 b) R end
* S3 u! h4 }6 i) D8 l; u5 N" w( @! @4 I2 f
to tt; U) ~1 v2 Z* x: Q2 i
ask patches [set pcolor gray ]$ s/ j7 `, y. d7 P6 Q0 u
ask turtles [set energy energy - 1]7 w9 J4 q6 J, X) g- ?+ @+ G
end, W) f! P6 C; f! _3 R2 Z
|4 d9 _; X* @( N |