mboeh / astar

A fully generic A* implementation in Rust

Home Page:http://tyoverby.com/astar/astar/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

A*

This is an implementation of the A* search algorithm in Rust. It is meant to be very general, and it should be possible to use this A* library for any A* search problem.

Api Docs

Requirements

In your search problem, each node must have Hash and PartialEq defined on them. The distance and cost associated with the problem must implement PartialOrd, Zero, and Clone.

Usage

In order to use the A* algorithm, you must frame your problem in a specific way. This is done by implementing the SearchProblem trait. The full trait is given here for clarity:

pub trait SearchProblem<N, C, I: Iterator<(N, C)>> {
    fn start(&self) -> N;
    fn is_end(&self, &N) -> bool;
    fn heuristic(&self, &N) -> C;
    fn neighbors(&self, at: &N) -> I;
    fn estimate_length(&self) -> Option<uint> { None }
}

Once you have an object that implements SearchProblem, you can perform a search like this:

    let path = astar(my_search_problem);

About

A fully generic A* implementation in Rust

http://tyoverby.com/astar/astar/


Languages

Language:Rust 100.0%