请问:
! W* | _9 z) X9 ^1 I/ Q5 v随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?
% S( B' H: C. _& W z* E. d/ f& d2 l6 k, O
* t& D; U: e3 ^" n& s1 wturtles-own [ energy ]
. z6 V, L7 a# f: i* O9 a" L% c0 Kto setup
' \5 f% A: ^/ Sclear-all
. ?9 N; M( X. q6 ^4 X- xset-default-shape turtles "square"
. c9 I# \; b1 A8 c' j# Ucrt nutrition
! n' @ [2 g+ x3 M/ G) oask turtles[" U. b* m8 L3 `4 G0 H) K
set color white, {$ Y/ `% R# s
setxy random-pxcor random-pycor]& t, H- Y7 V, @
. L; R1 ~! ?9 @0 Oask n-of microbes-initialization patches
( d* w" k; t7 h# G/ I [ set pcolor green]8 C- M1 D c8 |; S
ask turtles [set energy 1]+ b4 I% L2 t6 ^$ G& l/ ?
end
% N9 m) b, ~" y/ v5 ?7 G: X# R
0 v( L% e+ N" G. a2 j# [# lto go
9 m' V0 O0 |. s! H- G1 o& A, h6 Z ask turtles [set heading 90 * random 4 fd 1]
2 z6 u6 g: x+ L" ?2 o. k/ q; p ask patches with [ any? turtles-here]% B/ {. s. `; d* Y2 G" d
[ if pcolor = green and random 100 < chance-of-congregating [tt ]]1 `" c* D( ]' r! ]. j
ask turtles [ if energy = 0 [die ]]* V' S: a* I% ?: p$ J4 O1 e
end' a8 b1 n5 v. O
: E& v( K; T9 r/ ~$ W$ ^, r+ l
to tt
0 Y _ }1 p U! @7 \ask patches [set pcolor gray ]
' E( G% {0 b; e# m# C, Eask turtles [set energy energy - 1]* O( V1 G9 I; G/ a& Q7 B
end
: U* ~5 Y+ v$ j, y, d1 A/ m5 G2 |' o8 l4 w$ _3 P
|