HexMapPathFinder 0.0.5

There is a newer version of this package available.
See the version list below for details.
dotnet add package HexMapPathFinder --version 0.0.5                
NuGet\Install-Package HexMapPathFinder -Version 0.0.5                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="HexMapPathFinder" Version="0.0.5" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add HexMapPathFinder --version 0.0.5                
#r "nuget: HexMapPathFinder, 0.0.5"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install HexMapPathFinder as a Cake Addin
#addin nuget:?package=HexMapPathFinder&version=0.0.5

// Install HexMapPathFinder as a Cake Tool
#tool nuget:?package=HexMapPathFinder&version=0.0.5                

hex-map-pathfinder

A path finding library for hexagon maps.

Sample images of usage in possible environment

This image shows how reachableTiles is used on a map with different tiles (tiles with different movement costs). In this example reachableTiles computes all tiles that can be reached with movement value of 6 (up to 6 tiles). Plain and Sand costs 1, Wood and Hills costs 2, Mountains are unpassable. Alt text

With computePath it is possible to find shortest (with the lowest costs) path. Alt text

It ignores tiles that are not passable. If no path is possible, it returns an empty path. Alt text

Sample code

List<int> costMap = new() { 1, 1, 2, 3, 1, 2, 1, 3, 2, 4, 8, 1, 3, 1, 2, 1 };
var grid = HexGrid.InitializeGrid<Tile>(4, 4);
HexTile tile = new HexTile() { Coordinates = new CubeCoordinates(0, 0, 0) };
var pathFinder = new PathFinder(new List<List<int>>() { costMap }, 4, 4);
var reachableTiles = pathFinder.ReachableTiles(new CubeCoordinates(0, 0, 0), 2, 0);
// reachableTiles.length is 7

Example usage of ReachableTiles. It is important to initialize the component with a heatmap (a 2D map of all tiles used with movement value 0 → not passable, >1 cost for passing). reachableTiles is called with a starting coordinate in cube coordinate system and a max cost value.

List<int> costMap = new() { 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 1 };
var grid = HexGrid.InitializeGrid<Tile>(4, 4);
HexTile tile = new HexTile() { Coordinates = new CubeCoordinates(0, 0, 0) };
var pathFinder = new PathFinder(new List<List<int>>() { costMap }, 4, 4);
var path = pathFinder.ComputePath(new CubeCoordinates(0, 0, 0), new CubeCoordinates(2, 3, -5), 0);
// path.length is 7

Example usage of ComputePath. Compute path is called with 2 cube coordinates for start and end. A second version computePathOffsetCoordinates does the same, but start and end can be passed as offset coordinates (normal x and y values in 2D space). It returns all tiles of shortest path.

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.0.9 77 11/22/2024
0.0.8 86 10/31/2024
0.0.7 78 10/31/2024
0.0.6 68 10/31/2024
0.0.5 75 10/31/2024
0.0.4 79 10/27/2024
0.0.3 73 10/21/2024
0.0.2 126 10/18/2024
0.0.1 76 9/30/2024