请问:7 K3 y+ ^8 g- b4 l. J: G( V% m
随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?7 t, H _: U, P, ^8 G
! @6 p) w) r6 w$ o" d/ D) e
) ?' d }$ H- N! \+ S) w4 c
turtles-own [ energy ]* Y5 b$ }- B4 B1 c" @* N- [( d) e
to setup
( w- s* T8 A' ?( t, }2 W. G- r: Vclear-all
9 B. [# U. W3 J- B' Tset-default-shape turtles "square"
$ c0 e9 j f( U# P/ Qcrt nutrition' d. g. U# F# Q& U5 i
ask turtles[
" ~. p+ o6 ]+ r. m' v- y$ O: e set color white
9 \0 x ^4 Y- T, c& R- k2 ^ setxy random-pxcor random-pycor] U% N3 j3 \& @8 U
; }' h/ `2 B) q* f" {1 N$ qask n-of microbes-initialization patches( k7 ~: {4 R2 s# C' V
[ set pcolor green]
& q7 s; V% V; x4 r0 _% x ask turtles [set energy 1]
; t! ` V1 Q l# ?+ n6 \+ m- J+ \end! K1 L2 t, c. I) h2 i
' u9 L2 L8 _0 k" ~3 g( Z* A" Rto go
7 a! X# A( M0 m ask turtles [set heading 90 * random 4 fd 1]+ U0 A, ], O" h; b" l
ask patches with [ any? turtles-here]
3 q! E) U" Z/ j6 H ? [ if pcolor = green and random 100 < chance-of-congregating [tt ]]! C: A& [- `# Z% y8 @! {0 P0 j2 o
ask turtles [ if energy = 0 [die ]]8 e' i/ G: ~6 G% o! P+ M
end
, o4 w! i, `- n/ {3 N1 L9 a* g0 m& u0 c4 k f1 `8 K' M
to tt/ R( r9 u: A# [4 o# R5 I/ s4 N% \% h1 @
ask patches [set pcolor gray ]
4 x& K& o+ k- y3 }- ~' s7 {ask turtles [set energy energy - 1]! E% v4 [6 g, B
end
. s. F, o; m! s; v# B+ T9 I! {
O Q" r- D9 j% z+ Q; A; h; O |