请问:
" ^2 `6 k% W& ~* ? y8 K+ s) q随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?
0 u5 y, U/ k- t9 z8 Y
3 p) d/ g, e6 |8 c
# _8 t5 D+ h0 E! Oturtles-own [ energy ]* X, i d$ j: o) v7 m9 K( j9 z
to setup q' z% f9 i" y% N5 ]7 R7 \
clear-all/ u7 Y1 K5 E. f% p
set-default-shape turtles "square". R- t) ?8 S" b) B/ b
crt nutrition
4 b" d( L4 E1 F0 I# r; J( }ask turtles[: I' j! {$ S. p# @' Z
set color white2 \1 n$ W C W# p- G+ f5 a S
setxy random-pxcor random-pycor]$ I9 |% }' V4 i- r
1 n: W1 R+ V: {ask n-of microbes-initialization patches
4 g) I/ I1 ^0 f' R/ L+ y7 Y# t [ set pcolor green]
+ E& B8 ], E" z, U {3 B. s ask turtles [set energy 1]
( w9 D* X+ |5 ?9 @; k: eend* J3 Y& h% E( r
! X9 O1 o+ o* o& F3 B$ s- Gto go# c" G; @3 R) I
ask turtles [set heading 90 * random 4 fd 1]
& a( ^2 a5 J, @) a ask patches with [ any? turtles-here]
+ _1 f5 g2 ?: ~* r7 w [ if pcolor = green and random 100 < chance-of-congregating [tt ]]! _ f. F9 z- n2 p" G. w% S6 b3 O
ask turtles [ if energy = 0 [die ]]* u$ g0 M* L- I
end
! K! E: [# |' g: s
9 G. E: [! w' {/ d% zto tt
S! a% X' F* O1 O6 ^% ~ask patches [set pcolor gray ]& n4 n1 ~8 m* i
ask turtles [set energy energy - 1]
3 m: C# | V/ n& p1 G5 V; Nend
# O, p* ^7 P/ Q* a1 G' s7 N% L$ K: q v+ g& E
|