设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 5977|回复: 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吧 可能差不多# u2 ?2 d# c3 k; H
4 h. e" x5 ^3 L" @+ {- N
turtles-own[g h]. Z! H7 w: q/ |  l$ O8 L* A2 V
to setup% u7 p' @) J* N  F% z) X2 G
  ca 1 O: N) I: _' O' E; z
  crt 50[set shape "circle" setxy random-xcor random-ycor]" A3 M; p' P; B; W5 I% y0 U9 F5 q
end9 C1 a- F' v4 X, D) R
to go3 Z7 B6 h/ a: w4 P: e9 B0 g" W
  ask turtles [set g random-float 1506 G2 \6 y$ J$ _* D; M9 I
    set h random-float 50]
8 p, u% B  g; t! l, e  f( R2 |  
3 j& Y! U* o8 W, U  1 N) z; r, ~) a  `
  ask turtles
9 w: y! L2 P; u, a, x  [ifelse max-one-of turtles-on neighbors [g] != nobody' L8 h  S4 Z* y/ M
    - ~/ ~( `0 A! x. l# W
  [set h [h] of max-one-of turtles-on neighbors [g]]
7 n0 X* O$ s3 @5 s" n; d1 H4 r  [set h [h] of self]" N4 Z; j3 q- E( s0 d
  . B, K1 s: {  i: L  g  g6 G# {' A
  ]4 u$ r% l8 L; }3 R$ e  |( d
  / X# y/ h: t# d, r6 [! H
  end
; j. O) \7 g) `3 m类似这样的吧。

评分

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

查看全部评分

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

本版积分规则

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

GMT+8, 2025-10-29 18:01 , Processed in 0.014552 second(s), 16 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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