RafaelBarbosatec / a_star

Package that uses the A * algorithm to find a way to the destination through the barriers.
MIT License
18 stars 10 forks source link

Update a_star_algorithm.dart #10

Closed Horned-Nonsense closed 8 months ago

Horned-Nonsense commented 8 months ago

This allows us to move diagonally directly and makes the algorithm more versatile and also reduces the number of iterations. Exmpl grid:

XOOXE XXOOX XOOXX XOXXO SXOOX

Where: S - start, E - end, X - barrier, O - free space

RafaelBarbosatec commented 8 months ago

Hi @Horned-Nonsense ! Thanks so much for contributing! Some times we want not diagonal movement. Why did you remove withDiagonal param?

Horned-Nonsense commented 8 months ago

Hello @RafaelBarbosatec. Perhaps I was a little hasty in deleting it. After submitting the PR, I thought that not having diagonal transitions makes sense, for example if it's an obstacle in the game like a diagonal wall, so I could leave the diagonal clearance check. But if we consider the algorithm abstractly, then the possibility of diagonal moves should be preserved without taking into account the walls in the neighborhood.

Horned-Nonsense commented 8 months ago

@RafaelBarbosatec I return it back.

RafaelBarbosatec commented 8 months ago

LGTM! Thanks for contributing!