请问:
6 L% p" N, ]! s随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?
* R5 T* r D: F- v
! R K+ z# I6 | / S1 g& d& A5 C5 ^* w. b. D
turtles-own [ energy ]* D# S# ~3 ~. X
to setup
6 x6 X+ z( H' ?& l4 n, j; Zclear-all$ {- X; |* k/ |. s
set-default-shape turtles "square"' x( T ^" s# o
crt nutrition
/ M K: B: ]4 X8 ?- U. G2 Nask turtles[/ g3 }* ^; b2 |5 g$ k5 \
set color white
) _, ~8 S7 y) o& ~/ P# U setxy random-pxcor random-pycor]; w- ]2 \: Y% |
8 D7 A. N! ^0 `6 @
ask n-of microbes-initialization patches
3 x+ A) R6 g( N/ ^8 @ [ set pcolor green]
f# _, C# E) M0 W, d+ N& { ask turtles [set energy 1]; {2 M, D" r. S+ x% z$ X+ a5 g
end
- S7 |$ U) t% S) l7 A" z; e
; C$ C$ c7 d4 C, ^! x. Eto go, j) b! W4 [. G9 h; U% Y6 r- \
ask turtles [set heading 90 * random 4 fd 1]8 } }/ |+ N0 x
ask patches with [ any? turtles-here]
6 b/ m& N2 |0 C" N, w& c [ if pcolor = green and random 100 < chance-of-congregating [tt ]]
9 f2 V) r3 c8 ~. t- `! z7 E ask turtles [ if energy = 0 [die ]]3 G2 K) y* ^2 q5 @0 c
end
! y$ P `& S4 l# W& X- `
! v0 D3 @# b. _% S2 \) ~; W( vto tt
, _" l. b* C- C y2 M2 `+ |/ Uask patches [set pcolor gray ]5 I; ], X v( V
ask turtles [set energy energy - 1] Y" R4 G9 }# Y& |' f/ s
end
! V2 ^# i6 f5 ^" ]1 [" q# K0 E; V, J* b
|