请问:
% D1 Z t0 T/ I d随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?' o% E5 K9 H# G/ Q( u$ g" s, R' Q
) ^2 W% S5 y% y' {; J O5 q
( N4 P' {9 T9 Wturtles-own [ energy ]
# o% S: `+ I. q9 F4 Q) @to setup# \% o2 U/ K- y- B2 h# g1 x
clear-all
" m6 {1 [# J9 K0 Wset-default-shape turtles "square"
2 R" O( Q q5 j/ dcrt nutrition- \1 n9 k, S [9 o G
ask turtles[
+ c) Q2 ^6 s. M4 J8 J3 f set color white
- L( I1 ^ u' T* @ setxy random-pxcor random-pycor], W7 `; u( k# K; z% Q q5 ~: L
2 ~; _7 H/ A+ Sask n-of microbes-initialization patches
( H' p/ {) q; c" u4 }$ h X/ Q [ set pcolor green]
0 ]% w, M/ L1 M, g, y ask turtles [set energy 1]# g5 J" S# i% C$ }- `
end# A- \9 H6 Y7 B( y
4 z0 o4 s% w* j. \6 c. L. jto go/ s$ ~/ M/ B$ f" x! j
ask turtles [set heading 90 * random 4 fd 1]
. i0 i4 J+ g3 b' H# N( { ask patches with [ any? turtles-here]
/ L0 Y+ |; o* K- u0 l [ if pcolor = green and random 100 < chance-of-congregating [tt ]]% G0 M* S7 i) R3 [$ X! I2 c
ask turtles [ if energy = 0 [die ]]
* i( N' h- T# P5 Z$ n end
2 x/ u% X. X* D' c# z8 | V+ x
7 m+ v/ t- _% j% B+ ito tt
( j4 Q7 W9 n5 W; j9 gask patches [set pcolor gray ]
5 h' F a) t# P0 ?9 X1 n" j" aask turtles [set energy energy - 1]0 Q3 d8 p1 \. z5 B h
end
9 _( K' D$ m# J( S* k$ z# o3 h7 }0 D9 |( F# W' E% b
|