请问:# r5 m% C: s ]
随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?
2 F$ `8 n# g. i" v D
' Y9 L, l [2 u& T3 I9 T ! ]& x ~, C% K% P
turtles-own [ energy ]
: ]& x- E# g& R# i. p" k' Mto setup
( _) ?* g6 @; q; i% R4 Z4 ]0 hclear-all
. [! ^1 ` U, A& S: mset-default-shape turtles "square"
! Q/ I- _; |/ ~2 A$ Vcrt nutrition
, x! X4 a# I+ z" Eask turtles[9 e3 E/ @5 {3 u! d% w4 L
set color white% b, N W9 Q& d$ l( f) A/ v& M
setxy random-pxcor random-pycor] l6 W: c$ }4 |8 x
9 [- r& u9 T" T
ask n-of microbes-initialization patches
4 y, X! M! w6 Q- j' V [ set pcolor green]
' Q9 I, J5 |, L w ask turtles [set energy 1]- ?9 w, c7 v3 h1 {2 [
end
5 r0 l# C2 Y( E" h! W! E# t
. Z: `% N" i) S+ \to go
3 X3 N% W/ Y* m ask turtles [set heading 90 * random 4 fd 1]' d' z9 {, H7 Z( _" V) q
ask patches with [ any? turtles-here]
& @- {. U6 @' m# _! h [ if pcolor = green and random 100 < chance-of-congregating [tt ]]
( h) B- W5 \" m5 m ask turtles [ if energy = 0 [die ]]! @! F0 ~3 U) h. a. ?2 _7 t5 `% `
end
" I8 m# C1 C. a( S o3 t
# @% a7 l2 O# w& }3 O: Oto tt' v; e- K; ]* h9 s9 R" ~) Q, M6 o
ask patches [set pcolor gray ]# S# x+ d. g5 p o' f( p
ask turtles [set energy energy - 1]6 L; y% f/ l$ h5 E
end, E3 s1 O; J' m& \
. S j, R3 i+ R) u; \! d; m) L: f
|