Skip to content

Commit

Permalink
no message
Browse files Browse the repository at this point in the history
  • Loading branch information
selimanac committed Jul 11, 2019
0 parents commit cb73f5c
Show file tree
Hide file tree
Showing 14 changed files with 2,347 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/.internal
/build
.externalToolBuilders
.DS_Store
Thumbs.db
.lock-wscript
*.pyc
.project
.cproject
builtins
/.vscode
.vscode
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
testing
14 changes: 14 additions & 0 deletions astar/ext.manifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: "astar"

platforms:
x86_64-osx:
context:
flags: ["-std=c++11"]

arm64-ios:
context:
flags: ["-std=c++11"]

armv7-ios:
context:
flags: ["-std=c++11"]
88 changes: 88 additions & 0 deletions astar/include/Map.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
#ifndef Map_hpp
#define Map_hpp

#include <micropather.h>
#include <stdio.h>
#include <math.h>

using namespace micropather;

typedef struct {
int x;
int y;
} Position;

typedef struct {
int tile_id;
float* costs;
}Tile;


class Map : public Graph
{
private:
Map(const Map&);
void operator=(const Map&);

MicroPather* pather;

enum Direction
{ DIRECTION_FOUR = 4,
DIRECTION_EIGHT = 8
};

// E: 1/0
// N: 0/1
// W: -1/0
// S: 0/-1

// SW: -1/-1
// SE : 1/-1
// NW: -1/1
// NE : 1/1

// E N W S NE NW SW SE
const int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1};

int result;

public:
int worldWidth, worldHeight, tileCount, worldDirection;
int *world;
Position pathFrom = {0,0};
Position pathTo = {5,5};
MPVector<void*> path;
MPVector<StateCost> near;
Tile* Costs;

Map(){};
~Map();

enum
{
SOLVED,
NO_SOLUTION,
START_END_SAME,
};

void Setup(int _worldWidth, int _worldHeight, int _worldDirection, int _allocate, int _typicalAdjacent, bool _cache);
void SetMap(int *_world);
void ResetPath();
void ClearPath();
int WorldAt(int x, int y);
void NodeToXY( void* node, int* x, int* y );
void* XYToNode( size_t x, size_t y );

virtual float LeastCostEstimate( void* nodeStart, void* nodeEnd );
int Passable( int nx, int ny );
virtual void AdjacentCost( void* node, MPVector<StateCost> *neighbors );
virtual void PrintStateInfo( void* node ){};
float totalCost;
int Solve();
int SolveNear(float maxCost);
void Clear();
};


#endif /* Map_hpp */
Loading

0 comments on commit cb73f5c

Please sign in to comment.