Pathfinding on grids using jumping point search and connected components.

Overview

grid_pathfinding

A grid-based pathfinding system. Implements Jump Point Search with improved pruning rules for speedy pathfinding. Pre-computes connected components to avoid flood-filling behaviour if no path exists.

Example

Below a simple example is given which illustrates how to set a basic problem and find a path.

use grid_pathfinding::PathingGrid;
use grid_util::grid::Grid;
use grid_util::point::Point;

// In this example a path is found on a 3x3 grid with shape
//  ___
// |S  |
// | # |
// |  E|
//  ___
// where
// - # marks an obstacle
// - S marks the start
// - E marks the end

fn main() {
    let mut pathing_grid: PathingGrid = PathingGrid::new(3, 3, false);
    pathing_grid.set(1, 1, true);
    pathing_grid.generate_components();
    println!("{}", pathing_grid);
    let start = Point::new(0, 0);
    let end = Point::new(2, 2);
    let path = pathing_grid
        .get_path_single_goal(start, end, false)
        .unwrap();
    println!("Path:");
    for p in path {
        println!("{:?}", p);
    }
}

See examples for finding paths with multiple goals and generating waypoints instead of full paths.

You might also like...
🕺 Run React code snippets/components from your command-line without config

Run React code snippets/components from your command-line without config.

Components of Fornjot that are no longer actively maintained. Pull requests still welcome!

Fornjot - Extra Components About These are extra components from the Fornjot repository, that are no longer actively maintained. Fornjot's goal was to

Transform jsx/tsx files to reactive views in js/ts to use in Web Components, insert into DOM or integrate with other libraries/frameworks
Transform jsx/tsx files to reactive views in js/ts to use in Web Components, insert into DOM or integrate with other libraries/frameworks

viewmill Features | Installation | Getting Started | Notes | Examples viewmill is aimed to create complex UIs from a simple form of JSX. It statically

Supercharge your markdown including RSCx components.

rscx-mdx Render Markdown into HTML, while having custom RSCx components inside. Usage use rscx::{component, html, props}; use rscx_mdx::mdx::{Mdx, Mdx

AskBend: SQL-based Knowledge Base Search and Completion using Databend

AskBend: SQL-based Knowledge Base Search and Completion using Databend AskBend is a Rust project that utilizes the power of Databend and OpenAI to cre

fas stand for Find all stuff and it's a go app that simplify the find command and allow you to easily search everything you nedd
fas stand for Find all stuff and it's a go app that simplify the find command and allow you to easily search everything you nedd

fas fas stands for Find all stuff and it's a rust app that simplify the find command and allow you to easily search everything you need. Note: current

Navigating around TUM with excellence – An API and website to search for rooms, buildings and other places
Navigating around TUM with excellence – An API and website to search for rooms, buildings and other places

NavigaTUM NavigaTUM is a non-official tool developed by students for students, that aims to help you get around at TUM. Feel free to contribute. Featu

CLI search and replace | Space Age seD
CLI search and replace | Space Age seD

SAD! Space Age seD What does it do? Basically sad is a Batch File Edit tool. It will show you a really nice diff of proposed changes before you commit

🔭 Search Dash.app from Neovim with Telescope. Built with Rust 🦀 and Lua
🔭 Search Dash.app from Neovim with Telescope. Built with Rust 🦀 and Lua

Dash.nvim Query Dash.app within Neovim with a Telescope picker! The theme used in the recording is lighthaus.nvim. Note: Dash is a Mac-only app, so yo

Comments
  • Can't restrict diagonals

    Can't restrict diagonals

    Hello! I appreciate this crate's straightforward interface, but it would be most useful to me if there were some way to restrict the paths so that diagonals movements were never considered. I tried replacing all moore_neighbourhood with neuman_neighbourghood and move_distance with manhattan_distance, but I got stuck on the use of moore_neighbour, so it seems like the diagonal assumption is pretty baked in right now.

    opened by jdm 0
  • Differing paths for different directions

    Differing paths for different directions

    Hello!

    I'm very new to Rust and game development and this crate seemed like a good way to get started. I am however running into issues as the paths generated by the library are different when going in different directions.

    As an example:

    Computing path from Point { x: 14, y: 10 } to Point { x: 14, y: 25 }
    Found Some(461v0) at Point { x: 14, y: 11 }
    Found Some(462v0) at Point { x: 14, y: 12 }
    Found Some(463v0) at Point { x: 14, y: 13 }
    Found Some(464v0) at Point { x: 14, y: 14 }
    Found Some(465v0) at Point { x: 14, y: 15 }
    Found Some(498v0) at Point { x: 15, y: 16 }
    Found Some(499v0) at Point { x: 15, y: 17 }
    Found Some(500v0) at Point { x: 15, y: 18 }
    Found Some(501v0) at Point { x: 15, y: 19 }
    Found Some(502v0) at Point { x: 15, y: 20 }
    Found Some(503v0) at Point { x: 15, y: 21 }
    Found Some(504v0) at Point { x: 15, y: 22 }
    Found Some(505v0) at Point { x: 15, y: 23 }
    Found Some(506v0) at Point { x: 15, y: 24 }
    Computing path from Point { x: 14, y: 25 } to Point { x: 14, y: 10 }
    Found Some(506v0) at Point { x: 15, y: 24 }
    Found Some(505v0) at Point { x: 15, y: 23 }
    Found Some(504v0) at Point { x: 15, y: 22 }
    Found Some(503v0) at Point { x: 15, y: 21 }
    Found Some(502v0) at Point { x: 15, y: 20 }
    Found Some(501v0) at Point { x: 15, y: 19 }
    Found Some(500v0) at Point { x: 15, y: 18 }
    Found Some(467v0) at Point { x: 14, y: 17 }
    Found Some(434v0) at Point { x: 13, y: 16 }
    Found Some(433v0) at Point { x: 13, y: 15 }
    Found Some(432v0) at Point { x: 13, y: 14 }
    Found Some(431v0) at Point { x: 13, y: 13 }
    Found Some(398v0) at Point { x: 12, y: 12 }
    Found Some(397v0) at Point { x: 12, y: 11 }
    Found Some(396v0) at Point { x: 12, y: 10 }
    Found Some(427v0) at Point { x: 13, y: 9 }
    

    Here are two images displaying the different paths. As you can see, one of them is pretty strange. Just thought I'd let you know.

    Thanks!

    Screen Shot 2022-11-16 at 5 34 38 PM Screen Shot 2022-11-16 at 5 34 45 PM
    opened by bjrnt 0
  • crisscross: similar crate just linking in case you find it useful

    crisscross: similar crate just linking in case you find it useful

    Hey, I just saw this, nice crate!.

    I did something similar a while ago. crisscross was never published as a crate, but I used it in one of my games to have AI find the shortest path to a target + know when they have a clear shot at the player or not.

    I figured it wouldn't hurt to link this here so you may find something useful in there.

    opened by thlorenz 0
Releases(v0.1.1)
Adds back-and-forth jumping between current and previous focused windows to Sway.

sway-focus-back-and-forth Implements back-and-forth movement between the current and the previous focused windows. It also can be seen as a fix to thi

Vinícius Müller 4 Aug 11, 2022
Bevy Meshem is a Rust crate designed to provide meshing algorithms for voxel grids, enabling you to create cohesive 3D mesh structures from a grid of cubic voxels

Bevy Meshem Crates.io, docs Bevy Compatibility: Bevy Version bevy_meshem 0.11 main Bevy Meshem is a Rust crate designed to provide meshing algorithms

Adam 4 Aug 16, 2023
Jump Point Search Implementation for Path Finding, in Rust

jps : Jump Point Search in Rust. Jump Point Search Algorithm Implementation in Rust. Current implementation status JPS Implementation 3D case ✅ Lifeti

null 3 Dec 15, 2022
A cross-platform library for retrieving information about connected devices.

Devices devices is a cross-platform library for retrieving information about connected devices. Combined with a library like sysinfo, a more or less c

Hank Jordan 4 Jan 8, 2023
A CLI tool connected to GPT-3 to help find the right terminal command

Command Recall A CLI tool connected to GPT-3 to help find the right terminal command Install to install the cli: cargo install --git https://github.co

Camille Moatti 102 Feb 18, 2023
A* Pathfinding Visualisation in Rust

astar.rs A blazingly-fast A-Star search algorithm and visualisation written in Rust. GUI powered by egui. Allows for dynamic grid sizes and user-chose

Nikhil Henry 4 Nov 16, 2023
Wena is a micro-framework that provides an elegant starting point for your console application.

Wena was created by Nuno Maduro, and is a Rust Lang micro-framework that provides an elegant starting point for your console application. This project

null 251 Dec 11, 2022
Multiple precision floating point numbers implemented purely in Rust.

Multiple precision floating point numbers implemented purely in Rust. Rationale There are several notable implementations of numbers with increased pr

null 11 Nov 23, 2022
A GPT-3 access point through Nostr, powered by lightning

Geppeto A Nostr based API for GPT-3, powered on Lightning. The bot listens for event kind 29000 (inspired by NIP-9000) and will query the prompt to th

null 5 May 24, 2023
Rust Server Components. JSX-like syntax and async out of the box.

RSCx - Rust Server Components RSCx is a server-side HTML rendering engine library with a neat developer experience and great performance. Features: al

Antonio Pitasi 21 Sep 19, 2023