设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 6635|回复: 1

[求助] 请教starlogo的邻居在程序中怎么表示?感激不尽

[复制链接]
发表于 2009-7-13 18:19:36 | 显示全部楼层 |阅读模式
我现在正用starlogo做一个仿真。假设turtle有一个变量(比如:g),我想比较某个turtle的g 值和这个turtle的邻居(左右相邻的两个或某个)的g值大小,最后分别把g值最大的邻居turtle的一些属性变量赋给这个turtle.       我不能解决的问题是,不知道在starlogo中如何表示某个turtle的邻居,或者说在程序中如何提取到某个turtle的邻居的一些属性值,不知道这个程序代码如何写。
发表于 2010-5-9 21:45:16 | 显示全部楼层
用netlogo吧 可能差不多- t; a# j( w0 V# X# c) p

5 W- S) \5 ~; S6 `$ c7 u5 {1 {4 Pturtles-own[g h]
- W+ |" i+ t6 U/ {4 W+ Z, K) vto setup1 i- q) ]  i, w  f
  ca
8 R  V8 u* Q: _9 a# L" J/ ]" L  crt 50[set shape "circle" setxy random-xcor random-ycor]& n6 M$ ^& n, I- K
end
2 U; ]; n* \, Uto go9 r, Q4 h$ U' x9 J. x5 C4 q% y9 M' Z
  ask turtles [set g random-float 150
* w4 v7 C- x# Q/ J. r3 V0 d    set h random-float 50]" T, D" q, v3 f
  , h5 |! D9 Q- _) L2 s
  
1 R7 n9 P0 M4 S7 \8 g. b- X  ask turtles 1 ^/ U8 l3 s8 Q# D% V  A- t8 W
  [ifelse max-one-of turtles-on neighbors [g] != nobody
/ k2 ?+ R4 u7 e! k) S+ I# L+ j( D    % W+ R) r/ C7 K0 X* ~4 a% Z' ?
  [set h [h] of max-one-of turtles-on neighbors [g]]8 `0 f1 j; Z# Y+ N
  [set h [h] of self]
( \) A* d  W  N7 G* K0 p  9 o  {: @1 l! ?& S0 N& P
  ]
0 Q5 V" Y" Z0 _& q, v% }  7 r9 E2 _5 t/ l+ ?4 g7 p
  end
/ o8 w, ], n# h  ]类似这样的吧。

评分

参与人数 1仿真币 +10 收起 理由
苘苘 + 10

查看全部评分

您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2026-4-30 23:37 , Processed in 0.024738 second(s), 16 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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