Recent Posts
Pathfinding in Rust - Part 2 - BFS
In the last section, we created a grid-based map with tiles and code to render it. That puts us in a good position to start the pathfinding logic.
Start and end We’ll need a start and end point to track where we’re pathfinding to and from. Later on, I’d like to set this via mouse input, but for now, let’s just make them hard coded variables:
let start = Position { x: 0, y: 0 }; let end = Position { x: 7, y: 7 }; The basic idea of a pathfinding algorithm is to iterate through the grid by checking the neighbors of any one tile.
read more
Pathfinding in Rust - Part 4 - BFS cont
In the last section, we implemented a basic version of a breath first traversal. While that is nice and useful, let’s use it to find a path.
To start, we need to update the reached HashSet from last time, into a HashMap<Position, Option>. We’ll use this hash map to track where the tile was reached from. We can use this hash map as a sort of breadcrumb system to generate a path to a destination.
read more
Pathfinding in Rust - Part 1 - Setup
In this series my goal is to implement various pathfinding algorithms on a 2D grid, and bundle them up into a neat little program to run, test and tweak their parameters live as they run. This post will just cover the initial setup.
For this series I’ll be using Macroquad as a rendering/window engine.
Starting a window With Macroquad, starting a window is extremely easy:
use macroquad::{ color::BLUE, window::{clear_background, next_frame}, }; #[macroquad::main("pathfinder")] async fn main() { println!
read more