请问:9 J- [+ v* Y' x; }$ T( W* M
随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?& m0 Z5 _, m3 j
7 ^6 \4 A/ h- l* K, f + P' M3 ^, x' a
turtles-own [ energy ]- \9 u3 v0 H& \" s# [
to setup
/ o% M+ s- e3 Y( y2 Q1 Hclear-all
( N, A9 u2 H ?4 zset-default-shape turtles "square"+ s9 }/ }6 t$ ]# `& R# P1 U2 l
crt nutrition
. l1 N) ]+ p' _$ a7 ^6 Vask turtles[
9 E9 U) U8 T7 h. G U6 h! [; k set color white' b* A s# d8 o9 @
setxy random-pxcor random-pycor]
1 {0 \0 K4 f; J8 t) y
7 D. |* a, M0 S# O0 fask n-of microbes-initialization patches
% `$ Z1 W) t) a/ f w8 D$ | [ set pcolor green]
* R6 L+ t" O: L) Z x9 _- V ask turtles [set energy 1]
3 e8 p6 X) N9 Lend) e# C1 Z D% Q2 B7 U" R( ?
# b0 z# _7 G5 H0 T) z( K+ k
to go
" N8 \+ x- g- e ask turtles [set heading 90 * random 4 fd 1]
' |- J& K L8 M7 b: E. u( ^% p% |- o! ] ask patches with [ any? turtles-here]
: o9 { U O! l8 Q3 ] [ if pcolor = green and random 100 < chance-of-congregating [tt ]]6 ?% w* a0 U8 \2 D' \
ask turtles [ if energy = 0 [die ]]
8 U& o! W5 V* W8 Q" S+ R7 K end, J! N9 n- G" `6 p
" q6 ~* [2 i( R2 \& X9 [
to tt
2 b8 ^5 b2 {3 J* j+ W/ g# Z9 Bask patches [set pcolor gray ]: O& J) Y. Y" n8 t
ask turtles [set energy energy - 1], Y5 e; [9 J. k/ U9 p
end
% o4 I1 H a9 }# I, ?6 R- k0 R y2 \+ D# O) l0 Z7 e
|