Giter Club home page Giter Club logo

paths3d's Introduction

paths3D

What is paths3D?

paths3D is a pathfinding library written in Golang. Its main feature is simple best-first and shortest-cost path finding.

Fork goals

This is a fork form SolarLune's paths path finding library. The fork aims at adding a third dimension to the pathfinding system: height. Each cell will have a specific height level. By default, the pathfinding only can go 1 height unit up per cell. And can drop down infinite Blocks. Configuration is planned ;)

Fork Status

Feature State
Height Pathfinding
Add pathfinding with heiht levels
Finished
Step Heights
Make the height that can be stepped up configurable
Finished
Drop Heights
Make the height that can be dropped down at once configurable
Finished

Why did you create paths3D?

I was doing day 12 of the AoC and was wondering if there is a simple and straight-forward pathfinding library for this. I couldn't find a lib for this use-case, so I decided to create one. Because I didn't want to start from scratch, so I decided to fork the existing paths lib and extend it with a height level.

How do I install it?

Just go get it:

go get github.com/Simzahn001/paths3D

How do I use it?

Basically paths3D is based on a grid with cells. Each cell does have a position, walkability and height. Further you can specify a cost; lower price cells will be preferred during the path finding process.

To find a detailed and explained example to start, please take a look at the how-to.md.

Here is a whole example of the lib:

import "github.com/Simzahn001/paths3D"

func Init() {
	
    //create a grid with a string array
    layout := []string{
        "xxxxxxxxxx",
        "x        x",
        "x xxxxxx x",
        "x xg   x x",
        "x xgxx x x",
        "x gggx x x",
        "x xxxx   x",
        "x  xgg x x",
        "xg ggx x x",
        "xxxxxxxxxx",
    }
    grid := paths.NewGridFromStringArrays(layout)

    // After creating the Grid, you can edit it using the Grid's functions. In this case, we make the
	// cells to "walls". Note that here, we're using 'x' to get Cells that have the rune for the lowercase
	//x character 'x', not the string "x".
    grid.SetWalkable('x', false)

    // You can also loop through them by using the `GetCells` functions thusly...
    for _, goop := range grid.GetCellsByRune('g') {
        goop.Cost = 5
    }

    // This gets a new Path from the Cell occupied by a starting position [24, 21], to another [99, 78]. The next two Parameters
	// specify the maximum height that can be stepped up at once and the maximum height that can be dropped down at once.
	// The last two parameters are settings for diagonal movement between two cells.
    grid := GameMap.GetPathFromCell(GameMap.Get(1, 1), GameMap.Get(6, 3), 1, 5 false, false)

    // After that, you can use Path.Current() and Path.Next() to get the current and next Cells on the Path. When you determine that 
    // the pathfinding agent has reached that Cell, you can kick the Path forward with path.Advance().
	
}

Dependencies?

For the actual package, there are no external dependencies.

SolarLune's path docs:

GoDocs

paths3d's People

Contributors

simzahn001 avatar solarlune avatar simzahn avatar opensauce avatar

paths3d's Issues

Make Path Creating Simpler

Now, a creating a path looks like this:

firstPath := GameMap.GetPath(24, 21, 99, 78, 1, 5, false, false)

And thats completely horrible because there are wayyyyy to many arguments in this function.

My idea is to add something like a PathSetting object, where the settings are fields of this object. Then you must give the function just the PathSetting object.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.