请问:$ \+ @, P) k" }
随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?
% Z( m) t1 n. I: V2 c
- v* ]1 \' h E& c4 M$ M2 t
8 q! w J5 {! k. v& X, N7 aturtles-own [ energy ]
- [$ s% }1 f2 xto setup* R% G# C8 t' q0 s# {
clear-all3 n' K( X2 S2 W% r: I- k
set-default-shape turtles "square"
6 |; Q% M# S5 M; t! C$ Ecrt nutrition
' H( V. B5 V7 Q4 A% wask turtles[9 J# i; Q& H2 Y( W
set color white) f. P9 q6 A( A
setxy random-pxcor random-pycor]! b, v. b4 K& C
; w# D6 X! a" \3 `* x2 Y, ~
ask n-of microbes-initialization patches
. y7 w+ p# @! T! M: V [ set pcolor green]
- b1 l m5 z5 C! V7 u' _ ask turtles [set energy 1]6 N5 _9 T I( e" |7 r
end
2 N" I+ H% o a4 T1 X/ s
& y# Q8 P0 W2 h' }" d" {6 jto go
c( ?. j! ^# \) ^) Q ask turtles [set heading 90 * random 4 fd 1]' s' M8 w0 h2 t6 K; f: @- T
ask patches with [ any? turtles-here]
y4 ~. ]( m5 j8 R) u" ]5 ^ [ if pcolor = green and random 100 < chance-of-congregating [tt ]]
' z4 F+ W: C* v6 t/ ^1 \ ask turtles [ if energy = 0 [die ]]) }! D( S! C) a7 [) {. n
end
4 f: h \$ x8 U% P+ i. d% r1 W: W1 ~. A
to tt A, i" T( l' t$ I* R* o, ~5 ]
ask patches [set pcolor gray ]# ^% q2 _% C8 J- M/ D5 b
ask turtles [set energy energy - 1]
0 F. ~% N) o+ C# `" Vend
8 {4 T" D. o$ P, ~5 R% C2 Q5 B
B$ c* P" g9 A, J. @5 c; A |