请问:8 G1 w* B4 \, n! O: e
随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?
; x% t. {* }: b+ }+ Z" {2 k- k: l
% n% t1 c# o+ P/ R
turtles-own [ energy ]9 Q; L8 z8 V7 i8 |
to setup- u; o; }4 ]! w* D1 }0 Z
clear-all. Z9 B( O4 c% b# W" A# e: x1 k& |
set-default-shape turtles "square"
9 J A5 C7 ~& A! f( w$ V# @crt nutrition
+ l0 Z' {4 ~# \8 C& sask turtles[
' ]: k, h8 \( P8 z& o. k set color white
. i# Z0 W E6 O- V+ G. m+ |- A setxy random-pxcor random-pycor]
8 \/ D% O" S% A9 O. h, i3 i : x6 L9 b/ q2 L7 `3 @6 u
ask n-of microbes-initialization patches& W3 d. N3 O, e w' z2 P2 ]* T* a
[ set pcolor green]
& f' x( T& n o! E; d" ~/ F; W, B ask turtles [set energy 1]
: r% `/ ]8 w( h, V& I _end6 F" M) O1 w: Z# p' Z8 v
7 s+ u9 F$ O: T2 q/ y4 kto go
4 M' G) \0 e6 t( ]! X ask turtles [set heading 90 * random 4 fd 1]$ o2 n- n3 o9 [, V& i
ask patches with [ any? turtles-here]
, P0 N. p6 E. ]- c# F [ if pcolor = green and random 100 < chance-of-congregating [tt ]]
, l- a( D, c. } ask turtles [ if energy = 0 [die ]]
. f& i; N3 D* F9 ~3 k: W end3 @0 B& M5 M3 {4 s8 u( H
1 M+ x! _5 Y) J% I- ?2 Cto tt
. t3 o; T: [9 r) S9 Hask patches [set pcolor gray ]
; P8 O& }4 q; y. ^6 G2 }ask turtles [set energy energy - 1]8 U+ W @; t+ @) E
end
& j* J3 B2 f. T- L, p) C2 @
6 B8 f( \; q: |* N9 Y0 _ |