-
-
Notifications
You must be signed in to change notification settings - Fork 5
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
6 changed files
with
1,379 additions
and
1,727 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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 |
---|---|---|
@@ -1,91 +1,79 @@ | ||
#ifndef Map_hpp | ||
#define Map_hpp | ||
|
||
#include <dmsdk/sdk.h> | ||
#include <math.h> | ||
#include <micropather.h> | ||
#include <stdio.h> | ||
#include <math.h> | ||
#include <dmsdk/sdk.h> | ||
using namespace micropather; | ||
|
||
typedef struct { | ||
int x; | ||
int y; | ||
int x; | ||
int y; | ||
} Position; | ||
|
||
typedef struct { | ||
int tile_id; | ||
float* costs; | ||
}Tile; | ||
|
||
typedef struct { | ||
int tile_id; | ||
float *costs; | ||
} Tile; | ||
|
||
class Map : public Graph | ||
{ | ||
class Map : public Graph { | ||
private: | ||
Map(const Map&); | ||
void operator=(const Map&); | ||
|
||
MicroPather* pather = NULL; | ||
|
||
|
||
|
||
// 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; | ||
|
||
Map(const Map &); | ||
void operator=(const Map &); | ||
MicroPather *pather = NULL; | ||
// 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> nears; | ||
Tile* Costs; | ||
|
||
Map(){}; | ||
~Map(); | ||
|
||
enum | ||
{ | ||
SOLVED, | ||
NO_SOLUTION, | ||
START_END_SAME, | ||
}; | ||
int worldWidth, worldHeight, tileCount, worldDirection; | ||
int *world; | ||
Position pathFrom = {0, 0}; | ||
Position pathTo = {5, 5}; | ||
MPVector<void *> path; | ||
MPVector<StateCost> nears; | ||
Tile *Costs; | ||
|
||
enum Direction | ||
{ DIRECTION_FOUR = 4, | ||
DIRECTION_EIGHT = 8 | ||
}; | ||
|
||
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 SetToWorldAt(int x, int y, int value); | ||
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(); | ||
}; | ||
Map(){}; | ||
~Map(); | ||
|
||
enum { | ||
SOLVED, | ||
NO_SOLUTION, | ||
START_END_SAME, | ||
}; | ||
|
||
enum Direction { DIRECTION_FOUR = 4, DIRECTION_EIGHT = 8 }; | ||
|
||
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 SetToWorldAt(int x, int y, int value); | ||
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 */ |
Oops, something went wrong.