设为首页收藏本站

最大的系统仿真与系统优化公益交流社区

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 8598|回复: 1

[求助] turtle粘合patch的运动问题

[复制链接]
发表于 2008-4-8 10:49:43 | 显示全部楼层 |阅读模式
5仿真币
请问:
5 R4 y- C, q7 ~) X# t9 S& q" G* K随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?, Y& i/ H7 c  S0 R0 l
$ c* J; r& c+ c, F% B- M

- ~8 o9 n+ R- ^turtles-own [ energy ]* \2 h- z6 U/ N
to setup
5 u. ]" v, P3 b, N" {. c# U1 ?" Iclear-all- U/ x  H, O+ A. y$ |1 a- i
set-default-shape turtles "square"
5 S' t* p) p( @5 z" ]crt nutrition" J1 b, [0 k( s, |9 |; s) M
ask turtles[2 O- D6 j7 t+ \9 l6 s3 O  [
    set color white- |6 M* ^! P0 U* Q$ Q$ j
    setxy random-pxcor random-pycor]
$ n& F5 ?2 T. p; N% @  
2 w5 [6 k% r6 V% ^- Cask n-of microbes-initialization patches
0 Q; [: M+ S! ]: ]    [ set pcolor green]

7 w" Q+ x6 {3 Z ask turtles [set energy  1]7 K5 G8 ]0 |3 z/ m6 M4 E
end

' V! ^) [; I# B( e' }" v4 a, n' D+ F
to go
% e4 X6 Z+ C% M* `$ ~+ l; z1 L' c    ask turtles [set heading 90 * random 4    fd 1]
' \3 ^5 q- I3 }- g     ask patches  with [ any? turtles-here]
# I' w4 z1 a% k6 \) Z' ~' C    [  if pcolor = green and random 100 < chance-of-congregating [tt ]]
& H4 ]7 V" R8 T' `7 r3 b     ask turtles [ if energy = 0  [die ]]

) G' z, b0 E+ K! u end
$ R- t5 d; Y# K; j6 I
, Y% N" J+ l" C7 @to tt# o2 g' F; P% g( f
ask patches [set pcolor gray ]3 P4 m8 s+ e' x) {7 u# y' Y
ask  turtles [set energy energy - 1]
% g3 o" T( ^& D  _end
, O, r6 y; @: }; G7 _$ h4 M$ I+ R- d
 楼主| 发表于 2008-4-9 10:47:16 | 显示全部楼层
谢谢楼上两位,后来自己用两种turtle来表示暂时把问题解决了,以后再出现难题再向你们请教啊
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|Archiver|手机版|SimulWay 道于仿真   

GMT+8, 2026-4-6 08:12 , Processed in 0.013033 second(s), 11 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表