Grid of patches in adjacent squares of equal side length是否有在NetLogo中实现方块网格(补丁)的代码?每个正方形必须与其相邻的正方形直接相邻并对齐,并且所有正方形必须具有相同的边长(如图纸)。控制或改变正方形边长的功能将是理想的......
下面,我相信是一个用于生成此网格的示例代码,但具有随机的,未定义的边:
to generate-habitats [ habitat-spots ]
let habitat-ID 0
ask n-of habitat-spots patches [
set pcolor item habitat-ID base-colors
set habitat-ID habitat-ID + 1
]
while [ any? patches with [ pcolor = black ] ] [
ask patches with [ pcolor != black ] [
ask neighbors with [ pcolor = black ] [ set pcolor [ pcolor ] of myself ]
]
]
end
但我希望边缘在对齐的方形配置中是直的并且彼此相邻,而不是随机和锯齿状。