请问:" y- k% R+ ^1 \: C! S
随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?6 p" e8 I! Y8 Z# _, S; V% J
, I& d0 p1 N, ~4 e X
$ t L8 W& O2 |, J3 V% N6 m; Rturtles-own [ energy ]
( n5 ?" \ a. h. eto setup
9 v2 \# D# [9 Pclear-all
6 E/ z/ W7 L# S1 uset-default-shape turtles "square"
: E" U$ M9 z6 |% n+ V' Q' Icrt nutrition
8 ]8 T c6 E# p8 Y# ~( xask turtles[( ]0 b' I8 W5 F: m
set color white
0 V. x2 s2 U1 |, u1 _+ X# _ p* M setxy random-pxcor random-pycor]
y6 f4 k+ p- Z x. x3 }) |' C5 l % Z. M. S) }9 g& N3 h- E3 y; O
ask n-of microbes-initialization patches. A/ \$ i+ [, { G+ g
[ set pcolor green]
0 \7 r$ Z+ P! c1 }. ?5 ]! P8 L ask turtles [set energy 1]5 M$ q% Z/ Z* y9 `5 P% t) p1 m4 P; g
end9 A1 u9 P. Y. P4 z3 B7 N
2 H+ y! N, i6 y# ]
to go8 P. z( c) R0 x, m2 x, m& N
ask turtles [set heading 90 * random 4 fd 1]% k& e" d8 @ B0 X+ S3 ]/ c; s; V
ask patches with [ any? turtles-here]
( l. R7 U! o/ w/ n5 L( F6 o9 K [ if pcolor = green and random 100 < chance-of-congregating [tt ]]& \% g9 O# l7 B
ask turtles [ if energy = 0 [die ]]( E0 X- r: _6 B2 I7 c& s! `2 G
end
# I+ y0 J$ Z5 t: m$ ~+ i8 i, K& X, ]. C
to tt
5 S& V' N }- M/ `ask patches [set pcolor gray ]
4 Z9 e+ B7 y+ R# U; i& Q1 Zask turtles [set energy energy - 1]
5 a3 O; b. f* [# E7 s. @& U! Uend6 G& g$ n3 x- v+ S( O
3 J }! e5 N6 Q( O7 g( O1 G% K |