请问:
" g! `) }; {2 y) y随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?
! V# v7 R2 V7 n0 w2 J6 V
9 t! S: q- ~2 M# S: U6 w( J * s1 F5 F' s% C) K& O! i
turtles-own [ energy ]( M6 v' ]6 K) X& h
to setup8 y% @1 I4 s$ n* x5 _- p
clear-all
5 l- G+ H! \7 a3 V! nset-default-shape turtles "square": V! U8 C9 c, q/ w, Z) I% \
crt nutrition
% f! ~: M, s0 g" @9 ?6 l) J Qask turtles[
6 l) i9 F6 N3 |" q! J! w: K2 K set color white
" i7 h1 g) ^' u, ? |5 @, K: k# G setxy random-pxcor random-pycor]
( e5 h0 M9 h( v2 A
5 d& m7 [0 }0 R( g$ E7 f6 oask n-of microbes-initialization patches
1 \* U0 K" e9 O$ W [ set pcolor green]
3 x1 X1 F$ m2 a* \: t! o7 ? ask turtles [set energy 1]
! J& O: n2 n1 y& ~% Yend) N# Z& Q2 ?. f7 ^' a: v, u! I. i/ w
! r, i F2 Y5 }; v5 B3 P2 n' d- G4 tto go
; ~* e1 {: Z$ e$ S( h ask turtles [set heading 90 * random 4 fd 1]
8 O) {! }8 D6 b; M" }8 A4 x0 }0 V ask patches with [ any? turtles-here]
, S* t4 q0 v5 @2 R- s [ if pcolor = green and random 100 < chance-of-congregating [tt ]]
# T1 J2 r [8 ~- f/ [; C/ \5 k- x ask turtles [ if energy = 0 [die ]]
; u0 N1 {# d6 z" d8 [0 O! N0 [* a( D end
+ H5 y8 E' L, b* G' z, ]! ]4 w4 L
/ p( B& A+ s% L/ Uto tt
9 a+ n0 e" K& r; I6 cask patches [set pcolor gray ]
/ ]! S' c% R6 R6 V9 D" task turtles [set energy energy - 1]
' R) O# _6 g9 Z) b" Wend% N @! Q3 A9 Q% J9 p
( F3 O" X6 L& a* V |