diff --git a/README.md b/README.md index 77911fe..a7fec08 100644 --- a/README.md +++ b/README.md @@ -55,19 +55,19 @@ Y 0 | . . . . # . . . . . | - **`AStar::new(nodes: HashMap<(usize, usize), Node>) -> AStar`**: Creates a new A\* algorithm instance using the provided node map. This initializes the pathfinding algorithm and prepares it to find the shortest path between nodes. -- **`Node::grid_to_nodes(grid: &Vec>) -> HashMap<(usize, usize), Node>`**: Converts a 2D grid (with open cells and blocked cells) into a `HashMap` of `Node` objects. Each cell in the grid is represented as a `Node`, allowing for pathfinding operations to be performed. +- **`AStar::find_shortest_path(start: (usize, usize), goal: (usize, usize)) -> Result>, AStarError>`**: Finds the shortest path between the specified start and goal positions. Returns a vector of cells representing the path if successful, or an error if the pathfinding fails. -- **`find_shortest_path(start: (usize, usize), goal: (usize, usize)) -> Result, AStarError>`**: Finds the shortest path between the specified start and goal positions. Returns a vector of cells representing the path if successful, or an error if the pathfinding fails. +- **`Node::grid_to_nodes(grid: &[Vec]) -> HashMap<(usize, usize), Node>`**: Converts a 2D grid (with open cells and blocked cells) into a `HashMap` of `Node` objects. Each cell in the grid is represented as a `Node`, allowing for pathfinding operations to be performed. -- **`print_grid(grid: &Vec>, path: &Vec<(usize, usize)>)`**: Prints a visual representation of the grid with the given path highlighted. This function helps to visualize the pathfinding result on the grid. +- **`Node::print_grid(grid: &[Vec], path: &Option>)`**: Prints a visual representation of the grid with the given path highlighted. This function helps to visualize the pathfinding result on the grid. -- **`remove_neighbor(Direction)`**: Removes a neighbor in the specified direction (e.g., North, South, East, West, etc.) from a node. This is used to restrict movement options in that direction. +- **`Node::remove_neighbor(Direction)`**: Removes a neighbor in the specified direction (e.g., North, South, East, West, etc.) from a node. This is used to restrict movement options in that direction. -- **`set_neighbor(Direction, Option<(usize, usize)>)`**: Sets a neighbor for a node in the specified direction. The neighbor is indicated by its position `(x, y)`. +- **`Node::set_neighbor(Direction, Option<(usize, usize)>)`**: Sets a neighbor for a node in the specified direction. The neighbor is indicated by its position `(x, y)`. -- **`get_directions()`**: Returns a list of directions that are currently available from the node. This is useful for debugging or visualizing the movement options for a node. +- **`Node::get_directions()`**: Returns a list of directions that are currently available from the node. This is useful for debugging or visualizing the movement options for a node. -- **`set_blocked(bool)`**: Marks the node as blocked or unblocked. A blocked node will not be considered in pathfinding calculations, effectively acting as an obstacle. +- **`Node::set_blocked(bool)`**: Marks the node as blocked or unblocked. A blocked node will not be considered in pathfinding calculations, effectively acting as an obstacle. ### Basic Example