请问:+ L4 T2 y) D$ f, g6 z
随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?2 Y) _4 W( B8 t. Q+ a
2 R N' w: C3 h" ?' J: p: B# w: n - X: H0 h: O- ]% ?
turtles-own [ energy ]
; S9 A2 R$ b8 tto setup: Z9 r9 c) c: h) o% ~2 `, E( @
clear-all) t _1 D: q k# v; U l# Z/ Z4 N* ~
set-default-shape turtles "square"& ?, W3 a; ^% c; v* g8 |
crt nutrition2 _, ^4 z" e% ^: _, v. y9 b
ask turtles[
, j1 E8 M# `7 Q0 e set color white2 e4 i0 U. F) \! {! D
setxy random-pxcor random-pycor]
6 C; \2 d V- ` Z$ H0 H
/ u0 d: B% M& E4 S6 [/ Dask n-of microbes-initialization patches9 h) z% @, l0 e g9 V
[ set pcolor green]1 ^7 w; W t' T6 i& [- T6 m
ask turtles [set energy 1]
. i8 y) q) u' Y' nend7 f: }- _% l6 q9 m" B- _
$ D. _5 N, j3 ^5 k" s4 s% e
to go
0 n9 C/ C/ w5 z" \5 m4 O ask turtles [set heading 90 * random 4 fd 1]1 g" D2 x8 w$ i( Y! }6 L! U
ask patches with [ any? turtles-here]
. o% o$ p: u% i+ K, J1 l& V$ m [ if pcolor = green and random 100 < chance-of-congregating [tt ]]
) s2 r! a" k) H1 U$ i3 _2 a ask turtles [ if energy = 0 [die ]]
' L# l3 Q! B% b+ M end
# E+ D* F' \- Y
$ M$ A/ W/ e& L. E9 Wto tt8 b# `4 |+ M; M* \
ask patches [set pcolor gray ]+ M0 L& {6 n& @
ask turtles [set energy energy - 1]
U N2 e: P6 J I0 Mend" _. j5 i! h0 S9 v f
* x( K+ |6 s5 x" W/ \& m |