请问:
$ W$ b2 Q2 a! m, U; X; c& Z随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?
9 T$ J4 l' l! B$ {( b2 V+ J" y" T
& A6 L) ?" V" \2 S* b. x8 V
turtles-own [ energy ]( R0 Z4 \+ ?5 E2 m7 a
to setup' a8 m8 L0 k- j+ f6 v' y
clear-all
6 i& O: `, x7 C) y3 A: b: D: `set-default-shape turtles "square"7 }1 ^) G+ s* U8 Q6 c0 y
crt nutrition
+ ^; {: G' }* i& ^8 Z+ r- x Uask turtles[
2 a* K' d- G" e- _ set color white
6 L0 X+ K: ~+ L9 I. T setxy random-pxcor random-pycor]
; |; C/ }0 H) b3 ]- O
6 J3 @8 ]: x9 }$ O4 m- n9 }ask n-of microbes-initialization patches
* w; o: p) C. |7 X+ c4 G7 J$ [7 G [ set pcolor green] n! c; B- _- u f
ask turtles [set energy 1]
# g& A7 R# Z) Kend
2 t. s: U3 g/ w% p0 u
( B8 N& k' w1 _) I* ]" }to go
+ `; ~* _, }" W9 _/ c5 w' F0 c ask turtles [set heading 90 * random 4 fd 1]
/ j! i8 l" w& v! x/ u# v- U* [5 r% c ask patches with [ any? turtles-here]
3 y1 q0 Y% f. r" }" J [ if pcolor = green and random 100 < chance-of-congregating [tt ]]% h7 }) ~1 A0 L
ask turtles [ if energy = 0 [die ]]
- r x( U3 Y9 \- D end! V; x6 c3 G1 L" H
6 C3 v. l# K2 u) r
to tt
; T0 @7 C7 J( m" K7 X }ask patches [set pcolor gray ]5 j# C& e* t1 b7 v# A& _1 Z( D, F
ask turtles [set energy energy - 1]
* b0 x" q4 a# a# Pend
& B* X1 y' \" C. Y$ [: e% S6 b/ O$ I
3 Z! n" K% H1 m8 }( N! l* T% F1 z+ C |