Skip to content

Commit

Permalink
refactored terminology by replacing 'matrix' with 'grid' throughout c…
Browse files Browse the repository at this point in the history
…odebase
  • Loading branch information
selimserbes committed Aug 29, 2024
1 parent 28d03a3 commit 600d8f0
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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<Vec<u8>>) -> 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<Option<Vec<(usize, usize)>>, 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<Vec<(usize, usize)>, 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<i32>]) -> 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<Vec<u8>>, 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<i32>], path: &Option<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.

- **`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

Expand Down

0 comments on commit 600d8f0

Please sign in to comment.