请问:( F1 s4 ^' W/ e% V
随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?
g) [6 h0 _" y8 c+ h. B$ n: V# R# r
- ^9 Z" M. z* N+ m
turtles-own [ energy ]/ ?3 w. {( t$ Z4 c! ?
to setup
/ l9 Q! j) j0 L9 }7 sclear-all
- |# \2 w1 r. Y! g: Y( F: [set-default-shape turtles "square" l% @, n+ L% a, B! o
crt nutrition
/ u; x- {8 x$ b; ~+ ]# jask turtles[/ p2 R) p& O8 i1 v& m5 Y
set color white: o3 p) O% E1 E' S b4 g6 F; ~
setxy random-pxcor random-pycor]
: x1 ~$ D6 J$ O / d& U$ A2 A# X3 f5 a; i
ask n-of microbes-initialization patches
" {8 m( l! F% N- Z2 C$ y [ set pcolor green]
, A8 G$ C0 e* P+ C0 T; Y* G! ` ask turtles [set energy 1]
% | z$ y3 z5 V0 ] m, Gend* J' h. f; T8 v5 x% s% [
; V2 k8 [; P$ a' u# z
to go
% r V' h5 o; u ask turtles [set heading 90 * random 4 fd 1]- E$ z5 y( e! l1 I/ V
ask patches with [ any? turtles-here]
2 f& D( A! j$ S. |/ d4 b [ if pcolor = green and random 100 < chance-of-congregating [tt ]]
% q: w2 w8 f! Z6 I6 Q ask turtles [ if energy = 0 [die ]]1 ~6 N& v# w4 b) z) B% w
end* P- x3 |1 S9 [! ?: J5 i \
. a4 t& K, {7 ]
to tt7 `5 l& o) L r8 x$ I
ask patches [set pcolor gray ]
* c2 J' g( D2 B( Lask turtles [set energy energy - 1]
! a8 G- A' o# n5 v* kend2 N8 L3 u+ o( o( }; N/ G
$ x: a# S9 w' D7 ^/ N. D
|