将 NetLogo 世界分成几个随机部分 [英] divide NetLogo world into several random parts

查看:80
本文介绍了将 NetLogo 世界分成几个随机部分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在 NetLogo 世界上创建多个代理组.我希望每个组都位于一个特定的区域,没有重叠.据我所知,实现这一目标的最简单方法可能是首先将世界分成几个部分.每个部分由许多补丁组成(比如 100 + 随机 10,我可以设置)并用独特的颜色着色.然后让新创建的海龟移动到不同颜色的补丁.有人可以告诉我如何实现这一目标或提出任何建议吗?提前致谢.

I am trying to create a number of groups of agents on the NetLogo world. I hope each of the groups is located at a specific area without overlap. As I can think of, the easies way to achieve this might be dividing the world into several parts first. Each part consists of a number of patches (say 100 + random 10, which I can set) and is colored with a unique color. Then ask the newly created turtles to move to patches with different colors. Could anybody tell me how to achieve this or give any suggestion, please? Thanks in advance.

推荐答案

一种策略是发展不同的区域.例如:

One strategy is to grow different regions. For example:

to grow-regions [ num-regions ]
  let region-num 0
  ask n-of num-regions patches [
    set pcolor item region-num base-colors
    set region-num region-num + 1
  ]
  while [ any? patches with [ pcolor = black ] ] [
    ask patches with [ pcolor != black ] [
      ask neighbors with [ pcolor = black ] [ set pcolor [ pcolor ] of myself ]
    ]
  ]
end

请注意,这最多可以绘制 14 个不同的区域(因为这是基色的数量).

Note that this can draw at most 14 different regions (since that's the number of base colors).

这会导致区域如下:

误读您的评论.显然,这不会让您控制区域的大小,但平均大小将是 count 个补丁/num-regions.

Misread your comment. Obviously, this doesn't let you control the size of the regions, but the average size will be count patches / num-regions.

这篇关于将 NetLogo 世界分成几个随机部分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆