forked from daancode/a-star
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
27 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
## A* algorithm [![Build Status](https://travis-ci.org/da-an/a-star.svg?branch=master)](https://travis-ci.org/da-an/SHA-1) | ||
A* search algorithm written in C++ programming language. | ||
- requires compiler support for C++11 | ||
|
||
#### Usage example | ||
```cpp | ||
#include <iostream> | ||
#include "source/AStar.hpp" | ||
|
||
int main() | ||
{ | ||
AStar::Generator generator; | ||
// Set 2d map size. | ||
generator.setWorldSize({25, 25}); | ||
// You can use a few heuristics : manhattan, euclidean or octagonal. | ||
generator.setHeuristic(AStar::Heuristic::euclidean); | ||
generator.setDiagonalMovement(true); | ||
|
||
std::cout << "Generate path ... \n"; | ||
// This method returns vector of coordinates from target to source. | ||
auto path = generator.findPath({0, 0}, {20, 20}); | ||
|
||
for(auto& coordinate : path) { | ||
std::cout << coordinate.x << " " << coordinate.y << "\n"; | ||
} | ||
} | ||
``` |