Go to the documentation of this file.
45 int main(
int argc,
char* argv[])
115 printf(
"Window %ld destroyed\n", windowID);
134 printf(
"Window %ld created\n", windowID);
145 unitSims[windowID]->StepTime(1.0/30.0);
151 unitSims[windowID]->GetEnvironment()->GetMap()->OpenGLDraw();
157 glColor3f(1.0f, 0.0f, 0.0f);
158 Map *m =
unitSims[windowID]->GetEnvironment()->GetMap();
161 glVertex3f(x, y, z-3*r);
163 glVertex3f(x, y, z-3*r);
183 if (
a1.DoSingleSearchStep(
path))
185 printf(
"Solution: moves %d, length %f, %lld nodes\n",
202 if (
a2.DoSingleSearchStep(
path))
204 printf(
"Solution: moves %d, length %f, %lld nodes\n",
228 if (strcmp(argument[0],
"-map") == 0)
237 else if (strcmp(argument[0],
"-convert") == 0)
247 else if (strcmp(argument[0],
"-size" ) == 0)
262 case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
263 case '6':
case '7':
case '8':
case '9':
276 case 'p':
unitSims[windowID]->SetPaused(!
unitSims[windowID]->GetPaused());
break;
313 double sum1 = 0, sum2 = 0;
314 for (
int x = 0; x < 10000; x++)
342 printf(
"Far larger: %d, Avoid larger: %d, equal: %d\n", larger, smaller, same);
343 printf(
"Far: %1.3f; Avoid: %1.3f\n", sum1, sum2);
381 std::vector<graphState> thePath;
393 for (
int x = 0; x < 20; x++)
406 for (
int x = 0; x < 500; x++)
412 }
while (gEnv.
HCost(s1, g1) < 100);
417 taNew.
GetPath(&gEnv, s1, g1, thePath);
419 printf(
"old: %lld nodes expanded. Path length %d / %f. Time: %f\nrate0: %lld %f\n",
424 for (
int y = 1; y < 5; y++)
428 taNew.
GetPath(&gEnv, s1, g1, thePath);
430 printf(
"new: %lld nodes expanded. Path length %d / %f. Time: %f\nrate%d: %lld %f\n",
435 printf(
"\n\n\n!!!!!!!!!!!!!!!!!! IT FAILED!!!!!!!!!!!!!!!!!!!!!!!!\n\n\n\n");
450 unitSims[windowID]->GetEnvironment()->GetMap()->GetPointFromCoordinate(
loc,
px1,
py1);
455 unitSims[windowID]->GetEnvironment()->GetMap()->GetPointFromCoordinate(
loc,
px2,
py2);
460 if ((
px1 == -1) || (
px2 == -1))
462 unitSims[windowID]->GetEnvironment()->GetMap()->GetPointFromCoordinate(
loc,
px2,
py2);
463 printf(
"Searching from (%d, %d) to (%d, %d)\n",
px1,
py1,
px2,
py2);
479 a1.SetStopAfterGoal(
true);
480 a2.SetStopAfterGoal(
true);
void SetMode(tHeuristicCombination mode)
void AddHeuristic(node *n=0)
void MyRandomUnitKeyHandler(unsigned long windowID, tKeyboardModifier, char)
void MyFrameHandler(unsigned long windowID, unsigned int viewport, void *)
uint64_t GetNodesExpanded() const
std::vector< UnitMapSimulation * > unitSims
void InstallKeyboardHandler(KeyboardCallback kf, const char *title, const char *description, tKeyboardModifier mod, unsigned char firstKey, unsigned char lastKey)
bool MyClickHandler(unsigned long windowID, int, int, point3d loc, tButtonType button, tMouseEventType mType)
void SetNumUsedHeuristics(int count)
void InstallCommandLineHandler(CommandLineCallback CLC, const char *arg, const char *param, const char *usage)
void GetPath(environment *env, const state &from, const state &to, std::vector< state > &thePath)
Perform an A* search between two states.
GraphDistanceHeuristic * gdh
virtual double HCost(const graphState &state1, const graphState &state2) const
virtual void SetColor(const rgbColor &r) const
void SetNumPorts(unsigned long windowID, int count)
void InstallWindowHandler(WindowCallback wC)
void Scale(long newWidth, long newHeight)
void RemoveFrameHandler(FrameCallback glCall, unsigned long windowID, void *userdata)
void MyDisplayHandler(unsigned long windowID, tKeyboardModifier mod, char key)
virtual double GetPathLength(std::vector< state > &neighbors)
void SetActivePort(unsigned long windowID, int which)
bool fless(double a, double b)
int MyCLHandler(char *argument[], int maxNumArgs)
A templated version of A*, based on HOG genericAStar.
void SetTileSet(tTileset ts)
Choose the tileset used for land colors.
void CreateSimulation(int id)
This function is used to allocate the unit simulated that you want to run.
void SaveScreenshot(unsigned long windowID, const char *filename)
TemplateAStar< xyLoc, tDirection, MapEnvironment > a1
void SetPlacement(placementScheme s)
bool fgreater(double a, double b)
virtual double HCost(const graphState &state1, const graphState &state2) const
Heuristic value between two arbitrary nodes.
void InstallFrameHandler(FrameCallback glCall, unsigned long windowID, void *userdata)
std::vector< xyLoc > path
The basic simulation class for the world.
void MyPathfindingKeyHandler(unsigned long windowID, tKeyboardModifier, char)
void RunHOGGUI(int argc, char *argv[], int windowDimension=1000)
int GetNumPorts(unsigned long windowID)
void MakeMaze(Map *map, int corridorWidth, int startx, int starty)
MakeMaze(map)
unsigned int GetNum() const
void SetUseBPMX(int depth)
void MyWindowHandler(unsigned long windowID, tWindowEventType eType)
TemplateAStar< xyLoc, tDirection, MapEnvironment > a2
bool GetOpenGLCoord(int _x, int _y, GLdouble &x, GLdouble &y, GLdouble &z, GLdouble &radius) const
Get the openGL coordinates of a given tile.
int GetActivePort(unsigned long windowID)
A linked list of nodes which form a continuous path.
int main(int argc, char *argv[])
bool fequal(double a, double b, double tolerance=TOLERANCE)
GraphDistanceHeuristic * gdh2
void InstallMouseClickHandler(MouseCallback mC, tMouseEventType which)
virtual void OpenGLDraw() const
void Save(std::stringstream &data)
unimplemented.
void InstallHandlers()
Allows you to install any keyboard handlers needed for program interaction.
A tile-based representation of the world.