Skip to content

A* with cache (multiple start w/ same finish) #338

@IcanDivideBy0

Description

@IcanDivideBy0

Summary

Consider adding an A* implementation that can be reused multiple times for the same finish vertice.

Motivation

I'm currently building a simple navigation system for a game. Let's say there's multiple monsters targeting the same hero, they all have to find the shortest path to their target. Having a way to pre-populate the A* algorithm with a previous iteration would drastically reduce the cost of this computation (depending of the number of monsters of course).

Details

  • What code needs to change? New traits? Which modules?
    petgraph::algo::astar, not sure of the direction that it might take, but a I'm thinking of adding someting like this:
struct AstarInstance<'a> {
    graph, // &'a
    is_goal,
    edge_cost,
    estimate_cost,

    // cached structs from actual astar fn
    visited,
    scores,
}

impl AstarInstance {
  fn path_from(a: NodeId) -> Option<...> { ... }
}
  • Is this a new graph algorithm? Include links to papers, Wikipedia, or other
    No

  • Are you willing to implement this yourself? Mentor someone else and help them
    Yes!

Metadata

Metadata

Assignees

No one assigned

    Labels

    S-needs-triageStatus: Needs to be labelled

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions