请问:. P% N3 z$ L! U
随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?' M' V' i$ J; Z: k
" N) P5 a. q$ h7 k
& Q; e+ Q* V$ G; \- W0 W. S# [; `turtles-own [ energy ]
; K5 ~5 r( h2 I0 \* mto setup; H% }- M; M1 |4 Q4 x0 s
clear-all
+ {+ H/ m% X6 cset-default-shape turtles "square"
4 O& V: F6 ^$ a; ?8 rcrt nutrition$ r6 P7 Q' K6 s0 K: s( t6 F% ~8 a7 A
ask turtles[
* q8 n g' T; Z1 i* A( G set color white
- b8 q& }% S8 o setxy random-pxcor random-pycor]' u0 y1 c% p$ z4 Q$ v5 q
6 d6 K: l, O `8 `$ w# w& H& x
ask n-of microbes-initialization patches
5 U7 Y% L+ r" Q* l* F [ set pcolor green]
7 O* i5 ^3 _; g/ _. @ ask turtles [set energy 1]
) @% p I, O. x5 m+ j+ Vend) _$ [" P; x# I# H! ~' U
. G: w7 |& X( W( A& x8 P' zto go6 n v5 f' K" x. f
ask turtles [set heading 90 * random 4 fd 1]' K9 n9 ]! v/ _. c
ask patches with [ any? turtles-here]" R/ p1 y' b. ~+ B C
[ if pcolor = green and random 100 < chance-of-congregating [tt ]]
5 H% M3 h; `; A ask turtles [ if energy = 0 [die ]]
8 r/ c; Y7 x+ m* r" b end- b5 D- @. P4 q6 R, J( ?% x
$ f' N" d, _& i) v) X
to tt% r4 r- }, Y( _2 U: [/ h- j
ask patches [set pcolor gray ]8 } ?: I# `( H/ O) @+ P6 c+ U
ask turtles [set energy energy - 1]
$ {5 ]0 u L& E S3 P0 pend3 `: ]; @; T* A
& B* e8 D4 [' S/ F |