Giter Club home page Giter Club logo

astarpathfinding's Introduction

AStarPathFinding

an algorithm to find the shortest legal path between two points. Languages: Python -> .py C -> .c Java -> .java

Inside the AStarPathFinding.py file exists a function called 'find_shortest_path(start_position, goal_position, grid_dim, black_fields)'.
It takes: start_position | [x, y]
goal_position | [x, y]
grid_dim | [width, height]
black_fields | [[x1, y1], [x2, y2], ..., [xn, yn]]


The AStarPathFinding.c file also calculate the shortest path between two points. It do not now have a option to ignore barriers (black_fields). Example on how to use:

find_shortest_path(start_pos, end_pos, dimension, &fullpath);
for (int i=(fullpath.length); i>0; i--){
    printf("%d\t%d\n", fullpath.array[i][0], fullpath.array[i][1]);
}                        

There is now also a .java file. Take care the path returned by the find_shortest_path() function is from endpoint to startpoint (!). Example on how to use this:

shortest_path = find_shortest_path(start, end, dim); for (int i=(shortest_path.length - 1); i>=0; --i) { if ((shortest_path[i][0] != 0) || (shortest_path[i][1] != 0)) { System.out.println(Integer.toString(shortest_path[i][0]) + " " + Integer.toString(shortest_path[i][1])); System.out.println("_ _ _ _ _ _ _"); } }

HOPE THIS HELPS

astarpathfinding's People

Contributors

hannesbachmann avatar

Stargazers

 avatar

Watchers

 avatar

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.