请问:& S8 R/ v, v6 A- |
随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?
, w: `) W3 [2 m5 k& P; ]4 `+ z3 E7 X# P
% S$ b' a& S2 W8 g
turtles-own [ energy ]
7 G, v% V" h5 qto setup" K V5 ^# {$ x) }( P8 w( B8 B8 A! E
clear-all; a( n, B! ?) e: a8 h9 f% V0 p
set-default-shape turtles "square"" H: O) l! M" g6 n* M
crt nutrition- b6 }5 I( k8 U% {; r+ ]. |$ _
ask turtles[
7 [2 D3 G8 \ I% t; D! i set color white
" V6 q1 h" T; X Z setxy random-pxcor random-pycor]% S# r8 L7 J" Q ]5 ~. R
- h% \' T% U9 w2 e4 S# uask n-of microbes-initialization patches$ Z5 U9 g2 G5 z0 N3 D5 r
[ set pcolor green]6 C6 c/ ]: L* b- v1 Z) y
ask turtles [set energy 1]
/ E# `& C3 g* ~. T6 gend3 `! |) h( [% P* {
- w- b. n# z2 m l9 V
to go
$ K, G7 H4 D1 o4 i$ a( k# H ask turtles [set heading 90 * random 4 fd 1]
+ K% s0 e# @* K+ H" b; L ask patches with [ any? turtles-here]
7 Q, q4 C% E" Q i5 s9 G6 j2 f [ if pcolor = green and random 100 < chance-of-congregating [tt ]]
" i9 g$ B( D v4 g, W2 h% _ ask turtles [ if energy = 0 [die ]]
& M$ J3 i5 ^ q- c7 z end% n/ B# W4 `0 D# D" g4 I! e/ Y% u
1 ^& t; K$ y+ J; D- `
to tt4 `1 J2 S2 a: C8 `3 w! {
ask patches [set pcolor gray ]7 q$ S* ?% }4 Y
ask turtles [set energy energy - 1]( U0 j' ?. P: Y. _1 j" ~
end0 S! o5 [# `8 @( B
6 B! s- T& u% I9 ^( s |