请问:5 w, g: W; M o
随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?
$ ~: i+ h, o% h4 U& x- q. u5 D1 d/ n+ D% A
+ A; | `" [) `$ \4 m7 j
turtles-own [ energy ]
3 |; c: O7 H& q) z( p- R0 q3 Fto setup
8 u* d W% h' W" S. B% Z; dclear-all
) B+ i; {5 J2 X0 B( jset-default-shape turtles "square"7 ]' T( V( K' c! }
crt nutrition
+ H, V% s0 x0 @3 [ask turtles[8 N% q: F7 M/ \8 w
set color white
6 g1 ]* R* k7 s. T, l0 u5 m setxy random-pxcor random-pycor] Y. e2 K9 U% t$ f4 L: R
- N) Y* Z# b- t8 i( C
ask n-of microbes-initialization patches* `& |' [3 Y8 U/ L f7 A
[ set pcolor green]
$ J) J7 |% y0 _8 F5 Z/ ^% `% T ask turtles [set energy 1]
9 v/ C- r5 r! h" z1 [8 s, Dend
: v5 P; h' f7 Z9 Q. J. {
9 p! t9 [2 G( U$ E3 u- D6 p3 X* Mto go9 N9 m; [6 g# z$ k4 X
ask turtles [set heading 90 * random 4 fd 1]
( S) L* M j5 O, z! @' |, g5 b3 W ask patches with [ any? turtles-here]
# L; K0 q: t( b% r! W: J [ if pcolor = green and random 100 < chance-of-congregating [tt ]]
+ j* O* {& b/ z) i4 P ask turtles [ if energy = 0 [die ]]$ E: v- S3 N5 [0 e! i- S4 m
end
* y/ z# X) E% O9 Y5 j; ?" e' G+ B4 n" J1 Z# A3 G# i+ z
to tt
4 x: ?6 w- d& task patches [set pcolor gray ]
5 ]! Z0 Z" _* p! m' lask turtles [set energy energy - 1]
% H& L/ j5 s& Q, @end; U$ l2 o- ?& k- n1 X. l( A
- G9 L. c5 Q) N* |& T; G |