请问:
8 e& ]# Q# k+ x \/ m/ ]- @随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?
% r" b* e- j1 [4 \
) s5 u5 h4 }: Q3 d& m9 F
1 G1 Z- e T( A; R" \turtles-own [ energy ]- ^" u% k2 K R( c; `6 [3 A5 o3 e
to setup- q; D% C+ w* r; U8 s
clear-all
3 _ |. v" G/ T iset-default-shape turtles "square"
6 m5 d( Q0 ?# r& @+ v7 ucrt nutrition
. N6 ]; E& {4 I0 F$ Yask turtles[8 c' E% J( J* C7 c) R
set color white0 B; d- ~" ]4 _
setxy random-pxcor random-pycor]' n R) N% B5 ^' s; F% p, h
2 F& @0 S7 S' L3 J2 M5 S ?( v: Dask n-of microbes-initialization patches: h8 ?" {- o; |% q
[ set pcolor green]8 O* }1 ^; F! u' e w! v3 q4 y+ o
ask turtles [set energy 1]$ l$ M! O3 C& a8 R- [6 \4 H
end$ A: d$ U- @/ G/ b6 v
6 b3 R/ k4 t+ m: T# ]. r/ G2 B
to go
# B6 R* ]/ t' k. v6 T% `% P& f ask turtles [set heading 90 * random 4 fd 1]
) R' @2 U8 ~/ K. {' [4 f% K ask patches with [ any? turtles-here], `8 l" O3 A2 S8 S. |
[ if pcolor = green and random 100 < chance-of-congregating [tt ]]7 {3 p+ K* Y' V' u& W2 E7 ^3 N" L
ask turtles [ if energy = 0 [die ]]
& R; R/ ]1 T0 |; U2 v end9 G# i6 f: I+ ^0 F3 L( O" H# l( v
0 C" q" u+ H+ w$ g- eto tt, w; [% N5 {. Y5 f+ \
ask patches [set pcolor gray ]
8 a8 P" l. i( x1 M) D- S, V# W+ l9 d" [ask turtles [set energy energy - 1]3 L J5 u% s: _6 B8 y
end; L& E( W4 u. z& j9 i
% M/ V# b2 m& ?2 g' r. e
|