Skip to content

How to favor path with less turns? (A*) #57

@maximweb

Description

@maximweb

Thanks for this library. Being new to pathfinding, I used the A* basic example at it ran right away.

Is your feature request related to a problem? Please describe.
For my use-case, I set DiagonalMovement.never. I now was wondering, if it is possible to favor a path with less turns?

Describe the solution you'd like

  • In the following simplified grid, I want to get from s to e.
  • For the purpose of discussion, I drew to possible paths A (sxxAA..Axxe) and B (sxxBB..Bxxe).
  • Without diagonal movement, Path B has the same length as path A. Is it possible to tune settings(neighbor weights?) so that path A (having less turns) is favored over path B?
+----------+
|        ##|
| AAAAAxxe#|
| A    B ##|
| xBBBBB ##|
| x        |
|#s##      |
|####      |
+----------+

Describe alternatives you've considered

  • I was (naively) hoping that deliberately setting the start and endpoint in a recess of my blocked areas might help to favor path A, but I get B instead.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    Status

    No status

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions