• <i id='s5uyD'><tr id='s5uyD'><dt id='s5uyD'><q id='s5uyD'><span id='s5uyD'><b id='s5uyD'><form id='s5uyD'><ins id='s5uyD'></ins><ul id='s5uyD'></ul><sub id='s5uyD'></sub></form><legend id='s5uyD'></legend><bdo id='s5uyD'><pre id='s5uyD'><center id='s5uyD'></center></pre></bdo></b><th id='s5uyD'></th></span></q></dt></tr></i><div id='s5uyD'><tfoot id='s5uyD'></tfoot><dl id='s5uyD'><fieldset id='s5uyD'></fieldset></dl></div>
      <bdo id='s5uyD'></bdo><ul id='s5uyD'></ul>
    1. <legend id='s5uyD'><style id='s5uyD'><dir id='s5uyD'><q id='s5uyD'></q></dir></style></legend>

        <small id='s5uyD'></small><noframes id='s5uyD'>

        <tfoot id='s5uyD'></tfoot>

        在六边形网格上查找相邻邻居

        时间:2023-07-23
          <tbody id='iTyVN'></tbody>
        <i id='iTyVN'><tr id='iTyVN'><dt id='iTyVN'><q id='iTyVN'><span id='iTyVN'><b id='iTyVN'><form id='iTyVN'><ins id='iTyVN'></ins><ul id='iTyVN'></ul><sub id='iTyVN'></sub></form><legend id='iTyVN'></legend><bdo id='iTyVN'><pre id='iTyVN'><center id='iTyVN'></center></pre></bdo></b><th id='iTyVN'></th></span></q></dt></tr></i><div id='iTyVN'><tfoot id='iTyVN'></tfoot><dl id='iTyVN'><fieldset id='iTyVN'></fieldset></dl></div>
        <tfoot id='iTyVN'></tfoot>
        • <bdo id='iTyVN'></bdo><ul id='iTyVN'></ul>

                1. <legend id='iTyVN'><style id='iTyVN'><dir id='iTyVN'><q id='iTyVN'></q></dir></style></legend>

                  <small id='iTyVN'></small><noframes id='iTyVN'>

                2. 本文介绍了在六边形网格上查找相邻邻居的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  将示例地图包装在代码块中,以便格式正确.

                  Wrapped the example map in a code block so the formatting is correct.

                  好的,我正在尝试在六边形网格上编写一个极其简单的 A* 算法.我了解,并且可以做 A* 部分.事实上,我的 A* 适用于方形网格.我无法思考的是寻找带有六边形的邻居.这是 heagonal 网格的布局

                  Ok, I'm trying to write an extremely simple A* algorithm over a hexagonal grid. I understand, and can do the A* portion. In fact, my A* works for square grids. What I can't wrap my brain around is finding neighbors with hexagons. Here's the layout for the heagonal grid

                  0101     0301
                      0201      0401
                  0102     0302
                      0202      0402
                  

                  等等等等

                  所以,我需要帮助的是编写一个 Hexagon 类,给定它的十六进制坐标,可以生成邻居列表.它需要能够生成会脱离"网格的邻居(例如 20x20 网格中的 0000 或 2101),因为这就是我的 A* 跟踪并排放置的多个地图的方式.所以可以使用这个代码片段的东西:

                  So, what I need help with is writing a Hexagon class that, given it's hex coordinates, can generate a list of neighbors. It needs to be able to generate neighbors which would 'fall off' the grid (like 0000 or 2101 in a 20x20 grid) because that's how my A* tracks across multiple maps laid side-by-side. So something that would work with this code snippet:

                  行星 = 十六进制('0214')打印(行星.邻居())['Hex 0213', 'Hex 0215', 'Hex 0115', 'Hex 0315', 'Hex 0116', 'Hex 0316']

                  planet = Hex('0214') print(planet.neighbors()) ['Hex 0213', 'Hex 0215', 'Hex 0115', 'Hex 0315', 'Hex 0116', 'Hex 0316']

                  推荐答案

                  这取决于你如何定义你的十六进制图块的坐标.

                  It depends on how you define the coordinates of your hex tiles.

                  让我们看看.

                    ,   ,   ,   ,
                   /  /  /  / 
                  | A1| A2| A3| A4|
                    /  /  /  /
                    | B1| B2| B3|
                   /  /  /  / 
                  | C1| C2| C3| C4|
                    /  /  /  /
                    '   '   '   '
                  

                  在这种情况下,偶数行和奇数行的邻居定义是不同的.

                  In this case, neighbor definition is different for even and odd rows.

                  对于 Y 为偶数的单元格 (X,Y),邻居是:(X,Y-1),(X+1,Y-1),(X-1,Y),(X+1,Y),(X,Y+1),(X+1,Y+1)

                  For a cell (X,Y) where Y is even, the neighbors are: (X,Y-1),(X+1,Y-1),(X-1,Y),(X+1,Y),(X,Y+1),(X+1,Y+1)

                  对于 Y 为奇数的单元格 (X,Y),邻居是:(X-1,Y-1),(X,Y-1),(X-1,Y),(X+1,Y),(X-1,Y+1),(X,Y+1)

                  For a cell (X,Y) where Y is odd, the neighbors are: (X-1,Y-1),(X,Y-1),(X-1,Y),(X+1,Y),(X-1,Y+1),(X,Y+1)

                  这篇关于在六边形网格上查找相邻邻居的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:如何在 Matplotlib(Numpy)中生成 MATLAB 图(插值)? 下一篇:如何使用 tkinter 使用网格功能显示不同的图像?

                  相关文章

                  <small id='kx5No'></small><noframes id='kx5No'>

                  <tfoot id='kx5No'></tfoot>
                3. <i id='kx5No'><tr id='kx5No'><dt id='kx5No'><q id='kx5No'><span id='kx5No'><b id='kx5No'><form id='kx5No'><ins id='kx5No'></ins><ul id='kx5No'></ul><sub id='kx5No'></sub></form><legend id='kx5No'></legend><bdo id='kx5No'><pre id='kx5No'><center id='kx5No'></center></pre></bdo></b><th id='kx5No'></th></span></q></dt></tr></i><div id='kx5No'><tfoot id='kx5No'></tfoot><dl id='kx5No'><fieldset id='kx5No'></fieldset></dl></div>
                  <legend id='kx5No'><style id='kx5No'><dir id='kx5No'><q id='kx5No'></q></dir></style></legend>

                      <bdo id='kx5No'></bdo><ul id='kx5No'></ul>