请问:. n; ~, v# H# ?
随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?" i3 @; V0 O, n! s4 z
! e9 s/ h' ]+ b5 G/ N/ G
: J q' N# z# p2 d: pturtles-own [ energy ]
; J d8 u( r J3 fto setup' Y x/ t1 o) h# W6 \- j
clear-all4 P% \! I) M" A) c, ]
set-default-shape turtles "square", R/ H6 ], J+ a3 M! n+ c
crt nutrition- Y7 y% y+ f; J7 L$ ^
ask turtles[' Z( W+ X4 A6 a M
set color white* e9 i* [. t' y! C5 c
setxy random-pxcor random-pycor]1 O9 j1 c1 ~) S! h, i/ O: C* F
+ {+ N8 f% K* H0 z* fask n-of microbes-initialization patches1 o( j( K V8 ^7 g: M: a* Y
[ set pcolor green]
7 C; z" i) }9 H) I* b ask turtles [set energy 1]
7 k; n: y$ X! pend5 b" F/ ?+ e1 |5 s8 }
" |# p5 c# z9 s" h! H
to go
# K9 [/ K6 |, c ask turtles [set heading 90 * random 4 fd 1] ?0 l3 D N1 a) P) B9 A9 M" V) Y
ask patches with [ any? turtles-here]
- X2 L9 U+ d3 u/ E8 {" C; \ [ if pcolor = green and random 100 < chance-of-congregating [tt ]]; [; r; F5 ]2 t( U5 B; y( N
ask turtles [ if energy = 0 [die ]]. s# z+ ~) q+ e! L: X
end
- v( T1 v, J+ J `
+ i( x) x( ]9 E8 v" t' S+ d8 Gto tt3 B; h* x- V4 Y, O% m# v! i
ask patches [set pcolor gray ]
8 s" N1 L/ w; Gask turtles [set energy energy - 1] ^# d) k( B# f5 v( F: [' S6 K
end5 V" y- X& T' J3 ]
" r. b8 n. e. L% Z1 D
|