Skip to content

Grid does not allow an algorithm to make a diagonal crossing over a border #58

@andreyd41

Description

@andreyd41

Describe the bug
Grid does not allow an algorithm to make a diagonal crossing over a border

To Reproduce

from pathfinding.core.grid import Grid, DiagonalMovement

grid = Grid(5, 5)
grid.set_passable_left_right_border()

nb = grid.neighbors(grid.node(4, 2), DiagonalMovement.always)
print([(n.x, n.y) for n in nb])
print(grid.grid_str(path=nb))
[(4, 1), (0, 2), (4, 3), (3, 2), (3, 1), (3, 3)]
+-----+
|     |
|   xx|
|x  x |
|   xx|
|     |
+-----+

Expected behavior
I want to make diagonal crossings over a border. The code above should return:

[(4, 1), (0, 2), (4, 3), (3, 2), (3, 1), (3, 3), (0, 1), (0, 3)]
+-----+
|     |
|x  xx|
|x  x |
|x  xx|
|     |
+-----+

Screenshots / Map / Log
_

Environment (please complete the following information):

  • Environment: Ubuntu 22.04
  • Python version 3.10
  • Pathfinding Version 1.0.9

Additional context
_

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions