请问:7 r4 F7 P2 I/ F8 i, A. z. V: n
随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?
% R) `" f, {: [, N+ ?5 \& D8 b; @. ~, z2 F0 V! L
% s w& z* W$ |4 ?) t5 }; p4 C
turtles-own [ energy ]' c/ c5 _/ T, H6 I
to setup
/ f$ }, V6 n) w/ r) U' U& W; @clear-all! L, q$ H' H; \, h s$ h
set-default-shape turtles "square"
6 {0 v9 c) o& t$ Tcrt nutrition
. H% @8 L' D/ t. [4 W% a4 F& T1 cask turtles[
# c0 ^0 T1 F S+ j' a set color white
8 e7 b8 h* m$ J- K: t% X& s setxy random-pxcor random-pycor]/ D! R6 E" o* h( K; C: o
+ v0 O5 J3 i; {# Q4 task n-of microbes-initialization patches
o5 E7 a z# _0 g" l* i, U* r [ set pcolor green]: [2 o ] o; G |
ask turtles [set energy 1]/ p) g) A* ^3 Y) s" K
end
+ m5 A8 v- _. x( R: V
{1 @( d c( I( Ato go
, x& V: G/ E" b$ }" j9 @ ask turtles [set heading 90 * random 4 fd 1]- S7 h; S; s8 P; l# g
ask patches with [ any? turtles-here]
5 v7 s& N, L2 k0 P$ W# {8 K) ] [ if pcolor = green and random 100 < chance-of-congregating [tt ]]
+ s- _8 `; D$ b. ^2 V8 _6 Q ask turtles [ if energy = 0 [die ]]" A9 R3 b' Z: ~
end& a. V# ]3 P$ k& i) Z
; y5 a) r. I: |7 }! g" l6 W
to tt
l1 {, W; B/ hask patches [set pcolor gray ]
4 K! ?7 ?! ]9 U+ U5 c, h$ oask turtles [set energy energy - 1]
1 L5 y( H5 f3 B f1 @! r6 Mend
' J$ J, ?4 p- e- ], C7 ~8 a1 w* C! J
|