请问:+ ?$ Y- _- x8 b9 }. R- w- _
随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?
7 o# U" e" w4 L7 {6 U* k7 M/ `. A
: I- `0 y: ~( M. ^
1 t; ]& l- b2 }. g9 Wturtles-own [ energy ]
( Q+ R& K& y) |to setup
7 a: c. P- c) u* d2 {, [8 x J" Uclear-all
; h/ n& s \+ F9 E. Zset-default-shape turtles "square"/ q& e( s0 K }% _
crt nutrition
! o c5 L4 r3 Q; j! y1 I+ l6 T; zask turtles[. C4 X" }* }$ d% N0 A
set color white( G/ r0 J8 |% D9 l `
setxy random-pxcor random-pycor]9 u7 ^- Z, p* C2 l
2 w8 k$ c! a2 f; C$ Task n-of microbes-initialization patches
. L, }! z9 ~9 r3 E [ set pcolor green]$ c4 N2 v9 g' j3 f
ask turtles [set energy 1]
1 t# Z) I# k$ u, r5 _end/ Q7 C9 Z, n5 v% y1 v) N, u7 Q
8 w& a, Z: Q1 X) Z4 ~9 ~
to go, p c" F5 z* A/ E1 r
ask turtles [set heading 90 * random 4 fd 1]
" b- s9 Q& I& E! P+ X6 t& d7 J ask patches with [ any? turtles-here]
1 X" [( I: ]+ B [ if pcolor = green and random 100 < chance-of-congregating [tt ]]+ v- c' b( c& U8 c& {2 X/ E" z5 O, K, q
ask turtles [ if energy = 0 [die ]]
* \" Y& {. g. c* ~! |' s( `, x4 B end: w3 g( e% O1 h; |0 J4 ~( I- m9 {6 B
* d* R1 D; {% X$ c
to tt8 |9 ]2 W' U4 b
ask patches [set pcolor gray ]1 D3 c# O% [2 h2 s: T8 G6 X: U9 q
ask turtles [set energy energy - 1]1 V _7 d( }1 P g
end1 T3 A) w9 `$ K% f
" t( j) ?+ F$ S# z" \7 u. M
|