请问:
2 H. [$ h% D7 G& L0 q" h随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?9 ]& f% W# h8 u! S; J; @# O6 R* {
3 m5 g& u6 e F' b
8 m, G- U1 j3 ~+ zturtles-own [ energy ]5 f' }( _+ V+ }( _& H
to setup, _: H% E# Q" }$ |' d$ j; J
clear-all
$ S' {$ b; U, q/ M: Lset-default-shape turtles "square" u( H: E- z- `+ i6 P
crt nutrition
1 v7 _2 P ]. V# C" bask turtles[
# B" Z' {7 S1 a" u6 N6 X$ o7 Z set color white
" }# z0 K% m/ K# j9 } B; J4 z setxy random-pxcor random-pycor]
: l4 m1 z: J- T$ r2 ] 6 v9 g( A7 J: F/ b
ask n-of microbes-initialization patches
" v v5 [" U. X) z1 I N [ set pcolor green]8 s, f: C0 y8 }$ K( \: ]% q' ?
ask turtles [set energy 1]
7 s; [. w1 y& s7 Bend7 S$ b/ {4 B' [" p( C$ o; N
2 q5 y, v% a1 e( B7 P b
to go
9 b& y; t# J1 C2 r- b) N- l' F/ c ask turtles [set heading 90 * random 4 fd 1]1 V) G$ p6 u) m; m8 M: ]
ask patches with [ any? turtles-here] i3 G/ z! ^2 Y8 `
[ if pcolor = green and random 100 < chance-of-congregating [tt ]]! H q9 e" ^1 y0 L
ask turtles [ if energy = 0 [die ]]
% t6 e! m3 }/ p% Q end
& `/ e W0 j- G0 ^4 [3 K
5 O% q0 g W8 V5 Z3 rto tt
; N3 U8 W1 f0 N$ r) sask patches [set pcolor gray ]7 N( Z! K) g7 V" f# L0 B5 }" @: g
ask turtles [set energy energy - 1]
) j$ ~! ?4 r7 z4 A, c0 [1 yend9 q8 D8 p/ f4 H4 ?/ \! H0 {! B
" G: s2 Q j: ^$ {1 q ` R0 n6 N
|