请问:. { v [$ U& z7 k
随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?2 ~! a6 u& m0 n# W
8 o. n% }; h+ M8 G; T) H* g 1 a+ x% X$ l/ Z1 w, a# K
turtles-own [ energy ]2 a U; I: l5 n# ~$ |& I( V6 T( _
to setup$ U$ K( ~) D/ W0 _2 S3 |/ _. J
clear-all
6 X U/ T5 S5 E% j. I0 m: e8 ?set-default-shape turtles "square"
8 [. f$ {. J3 |8 c/ D8 acrt nutrition- P+ {1 n( E* C i( \5 u
ask turtles[
3 ~$ }# P, p/ e" t: {" F set color white9 D4 V8 L+ p8 @
setxy random-pxcor random-pycor]1 V+ x' r) t, [4 G
! H( F$ d, e) s. v# ]* |
ask n-of microbes-initialization patches
, F2 n$ L7 L$ ~7 u. w [ set pcolor green]! E+ C% a8 n: b- q4 Z. {9 K6 P1 `
ask turtles [set energy 1]
. y$ h" U7 U' B: v; x! Cend0 e& f* e% W; ^0 s
3 C; k- r8 ~" Tto go
" m& Y6 m- F( ]- C$ y$ z ask turtles [set heading 90 * random 4 fd 1]
3 ?$ |+ y% t) r6 k6 E* n8 R ask patches with [ any? turtles-here]9 k# u. Q5 Z8 ?$ S
[ if pcolor = green and random 100 < chance-of-congregating [tt ]]
1 m: T; ~# n; W2 T1 W0 Z4 a ask turtles [ if energy = 0 [die ]]
+ {( w+ X9 F- H3 g) { end2 x6 p7 l i8 Y. h* H4 K9 m
* X: l* A) C# b& q. @1 {; hto tt- q* x& Q! y i5 p6 h/ p
ask patches [set pcolor gray ]4 X! q# {1 h5 V B+ P+ W' D
ask turtles [set energy energy - 1]1 d, D" f% y0 h. s0 k8 Z
end
( o% W5 \+ k8 e4 R V3 n$ j; W5 w% O0 E
|