请问:7 g: y" y( v5 q2 K
随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?
0 T+ Y/ L2 k. S# n1 w( \% J7 e) u& M7 q5 j0 d$ ]
" B& `3 q7 d. G" ^/ N- ~: Zturtles-own [ energy ]
- T! u* [+ b: P% b7 w, S7 o! `to setup
- y# I" W- c; ^' S. l/ C. ^clear-all' x; `2 Q N$ c! A& q
set-default-shape turtles "square": z% ]& \3 W* Z9 M
crt nutrition
! y" P# K! d2 q# D& d" Rask turtles[
" L6 N# B; P' K; ^ e6 t set color white+ T& [3 x( b. d* ]# v& \" U
setxy random-pxcor random-pycor]% q0 w2 }+ L3 [/ @5 W
! ^; z1 I; [# X8 T& ]: L# w- L; @ask n-of microbes-initialization patches
$ l+ `( |# }6 A' O& Q [ set pcolor green]
( v2 J0 i% `; p8 f: ]+ p$ ]# V; {2 Y, E ask turtles [set energy 1]
; i2 f" s( W6 Tend
7 l9 X6 F" m. b( j8 M6 b8 m. b, ]+ R. z9 k- ~6 z" f6 F( _
to go
. x' g/ f/ w! r K4 N& {& k ask turtles [set heading 90 * random 4 fd 1]0 P; h0 w2 Z8 y+ X6 c# V5 l6 E; J2 [
ask patches with [ any? turtles-here]
3 N+ M; A) s+ Z$ T [ if pcolor = green and random 100 < chance-of-congregating [tt ]], ]( O U4 v4 G
ask turtles [ if energy = 0 [die ]]
$ A) Y) n8 v" u2 f. V8 f4 R! d; H end
+ e; o7 ~, N' W( k( D1 ^& v/ n- d
/ w' n2 s/ c4 j I! \to tt- h! S$ G7 i. T& K& p: ~
ask patches [set pcolor gray ]
( G6 @8 @: W0 eask turtles [set energy energy - 1]5 y) a5 h# Y7 Y% o% D
end j: g# [) p) {7 B
! r( i: L; ~4 h" _: y7 s/ i3 {
|