请问:5 b. D* b! i. k5 _ E
随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?/ b$ y) g9 b) g) u, T( l
5 c% d, x! f+ G% Z6 {
, |, b% O; U, t
turtles-own [ energy ], v4 @ ~9 U, F1 ]2 T
to setup4 G/ r X8 [8 T ~& \
clear-all5 k4 P* W; M& v: |& Z
set-default-shape turtles "square"
8 H# M9 C% d& I m- Mcrt nutrition2 @6 s/ t9 e, J, }) Q2 _! F O
ask turtles[: e: @" j, {. c9 v/ ]7 g
set color white; |, O- L1 U% E! k# G" M
setxy random-pxcor random-pycor]" i2 i& K; |! v, E& e. {
8 h7 @! j( z" K' }* f
ask n-of microbes-initialization patches
^, }7 \5 Z4 H% @9 m/ S2 y [ set pcolor green]
+ l7 H. c2 w$ ~6 ]; o ask turtles [set energy 1]
2 t1 D. a$ x/ q/ O5 z) A5 h3 Send
+ Z/ G I I+ ^* q U. r' H# f1 x a0 Y+ w* a! m
to go
$ {5 v( g9 Y! S ask turtles [set heading 90 * random 4 fd 1]1 n9 S% _. b( h2 [2 W3 r ?
ask patches with [ any? turtles-here]7 b! h- y6 q/ P% m2 A
[ if pcolor = green and random 100 < chance-of-congregating [tt ]]
# m/ G, u" a8 x0 U/ j" e ask turtles [ if energy = 0 [die ]]" b( v' q0 ~$ V D( U$ t
end6 q1 B6 n* ], P6 }# C
7 y L$ @2 B$ w9 {+ N7 i
to tt1 N1 d* H, a7 C* J, q7 t% r
ask patches [set pcolor gray ]
' w7 F% U! [- [& _, ^4 b' [; Bask turtles [set energy energy - 1]
* B1 p0 |: j& r& ~end
# n1 k2 M; U+ ]1 ~' Q: O n% j$ x( z# g6 c$ e9 c
|