请问:! Z! c. }8 d7 i- ~* x5 |8 W& o
随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?
8 s: h* U3 k2 j/ w0 ^" D0 n- A4 ~% o6 ?' w- k. h
1 x2 H6 R! j, k) `: o' f& F9 zturtles-own [ energy ]0 C1 j4 l) E, N$ C
to setup/ A! I3 S# r2 {
clear-all! A9 V6 n* Q! s" { ]* D. @ L6 D0 [
set-default-shape turtles "square"
! ]* ~1 h7 O l/ t8 ^: {, ^crt nutrition5 L: M) T- s+ x0 N; K7 _/ A
ask turtles[
" u e9 D+ J) `0 S set color white2 {- d B& [4 l1 S6 u
setxy random-pxcor random-pycor]" z: C8 a* G2 q* a4 u
4 u. x% V9 l! V8 Uask n-of microbes-initialization patches
4 Q7 l/ d5 e7 G# U( ~5 { [ set pcolor green]
, w; W5 U9 O6 p ask turtles [set energy 1]
9 r {; S4 a& q1 L/ qend, u" y3 o0 V+ F" t1 t; f0 R5 Q
3 q! R: I, U: e4 x* wto go" G$ T- a- H) t A1 l& f" u) ~
ask turtles [set heading 90 * random 4 fd 1]
; g2 B% p! V) N7 c ask patches with [ any? turtles-here]
4 f4 Z9 g0 s- p8 J* n+ h O( l I [ if pcolor = green and random 100 < chance-of-congregating [tt ]]
, |4 j; c$ h+ n ask turtles [ if energy = 0 [die ]]$ f2 @% l. F3 s* a
end
S- g: b2 ]) R" _8 b4 @8 W/ z% H' B2 i3 n R# ?
to tt, x/ c& f" g+ d; G) x# H9 s1 Y
ask patches [set pcolor gray ]7 n4 k) C( h0 \& D# `& n$ C
ask turtles [set energy energy - 1]* W7 w7 I* r( E6 _ ~" G
end9 ^0 B7 J( g5 o7 c+ G, y
, O9 ^9 |* s" V! X& \' G" O
|