HOG2
MotionCaptureMovement.h
Go to the documentation of this file.
1 //
2 // MotionCaptureMovement.h
3 // hog2 glut
4 //
5 // Created by Nathan Sturtevant on 11/9/13.
6 // Copyright (c) 2013 University of Denver. All rights reserved.
7 //
8 
9 #ifndef __hog2_glut__MotionCaptureMovement__
10 #define __hog2_glut__MotionCaptureMovement__
11 
12 #include <iostream>
13 #include "SearchEnvironment.h"
14 #include "UnitSimulation.h"
15 #include "FPUtil.h"
16 
18 public:
19  float x, y;
20  float heading;
21 };
22 
23 static bool operator==(const mcMovementState &l1, const mcMovementState &l2)
24 {
25  return ((abs(l1.x-l2.x)<0.01) &&
26  (abs(l1.y-l2.y)<0.01) &&
27  ((int)l1.heading==(int)l2.heading));
28 
29 }
30 
31 static std::ostream& operator <<(std::ostream & out, const mcMovementState &loc)
32 {
33  out << "{ (" << loc.x << ", " << loc.y << ") - " << loc.heading << "}";
34  return out;
35 }
36 
37 typedef int mcMovementAction;
38 
39 class MCEnvironment : public SearchEnvironment<mcMovementState, mcMovementAction>
40 {
41 public:
43  virtual void GetSuccessors(const mcMovementState &nodeID, std::vector<mcMovementState> &neighbors) const;
44  virtual void GetActions(const mcMovementState &nodeID, std::vector<mcMovementAction> &actions) const;
45  //virtual int GetNumSuccessors(const mcMovementState &stateID) const;
46  virtual mcMovementAction GetAction(const mcMovementState &s1, const mcMovementState &s2) const;
47  virtual void ApplyAction(mcMovementState &s, mcMovementAction a) const;
48 
49  virtual void GetNextState(const mcMovementState &, mcMovementAction , mcMovementState &) const;
50 
51  virtual bool InvertAction(mcMovementAction &a) const;
52 
54  virtual double HCost(const mcMovementState &node1, const mcMovementState &node2) const;
55 
58  virtual double HCost(const mcMovementState &node) const
59  { assert(bValidSearchGoal); return HCost(node, searchGoal); }
60 
61  virtual double GCost(const mcMovementState &node1, const mcMovementState &node2) const;
62  virtual double GCost(const mcMovementState &node, const mcMovementAction &act) const;
63  virtual bool GoalTest(const mcMovementState &node, const mcMovementState &goal) const;
64 
66  virtual bool GoalTest(const mcMovementState &node) const
67  { return bValidSearchGoal&&(node == searchGoal); }
68 
69  virtual uint64_t GetStateHash(const mcMovementState &node) const;
70  virtual uint64_t GetActionHash(mcMovementAction act) const;
71 
72  //virtual double GetPathLength(std::vector<mcMovementState> &neighbors);
73 
74  virtual void OpenGLDraw() const {}
75  virtual void OpenGLDraw(const mcMovementState&) const;
77  virtual void OpenGLDraw(const mcMovementState&, const mcMovementState&, float) const;
78  virtual void OpenGLDraw(const mcMovementState&, const mcMovementAction&) const;
79  void GLDrawLine(const mcMovementState &a, const mcMovementState &b) const;
80 private:
81  double distance(const mcMovementState &n1, const mcMovementState &n2) const;
82  bool GetOpenGLCoord(float x_, float y_, GLdouble &x, GLdouble &y, GLdouble &z, GLdouble &radius) const;
83 
84 };
85 
86 
87 #endif /* defined(__hog2_glut__MotionCaptureMovement__) */
loc::x
int x
Definition: MapGenerators.cpp:296
UnitSimulation.h
MCEnvironment::ApplyAction
virtual void ApplyAction(mcMovementState &s, mcMovementAction a) const
Definition: MotionCaptureMovement.cpp:119
MCEnvironment::HCost
virtual double HCost(const mcMovementState &node) const
Heuristic value between node and the stored goal.
Definition: MotionCaptureMovement.h:58
MCEnvironment::GetStateHash
virtual uint64_t GetStateHash(const mcMovementState &node) const
Definition: MotionCaptureMovement.cpp:165
MCEnvironment::OpenGLDraw
virtual void OpenGLDraw() const
Definition: MotionCaptureMovement.h:74
MCEnvironment::GetNextState
virtual void GetNextState(const mcMovementState &, mcMovementAction, mcMovementState &) const
Definition: MotionCaptureMovement.cpp:131
loc::y
int y
Definition: MapGenerators.cpp:296
MCEnvironment::GetAction
virtual mcMovementAction GetAction(const mcMovementState &s1, const mcMovementState &s2) const
Definition: MotionCaptureMovement.cpp:102
mcMovementState::x
float x
Definition: MotionCaptureMovement.h:19
FPUtil.h
MCEnvironment::GetActions
virtual void GetActions(const mcMovementState &nodeID, std::vector< mcMovementAction > &actions) const
Definition: MotionCaptureMovement.cpp:79
mcMovementState
Definition: MotionCaptureMovement.h:17
MCEnvironment::GetActionHash
virtual uint64_t GetActionHash(mcMovementAction act) const
Definition: MotionCaptureMovement.cpp:173
mcMovementState::y
float y
Definition: MotionCaptureMovement.h:19
MCEnvironment::GetSuccessors
virtual void GetSuccessors(const mcMovementState &nodeID, std::vector< mcMovementState > &neighbors) const
Definition: MotionCaptureMovement.cpp:55
mcMovementState::heading
float heading
Definition: MotionCaptureMovement.h:20
MCEnvironment::GLDrawLine
void GLDrawLine(const mcMovementState &a, const mcMovementState &b) const
Definition: MotionCaptureMovement.cpp:295
loc
Definition: MapGenerators.cpp:296
SearchEnvironment< mcMovementState, mcMovementAction >::searchGoal
mcMovementState searchGoal
Definition: SearchEnvironment.h:113
SearchEnvironment< mcMovementState, mcMovementAction >::bValidSearchGoal
bool bValidSearchGoal
Definition: SearchEnvironment.h:112
mcMovementAction
int mcMovementAction
Definition: MotionCaptureMovement.h:37
MCEnvironment::GoalTest
virtual bool GoalTest(const mcMovementState &node) const
Goal Test if the goal is stored.
Definition: MotionCaptureMovement.h:66
MCEnvironment::InvertAction
virtual bool InvertAction(mcMovementAction &a) const
Definition: MotionCaptureMovement.cpp:137
MCEnvironment::GoalTest
virtual bool GoalTest(const mcMovementState &node, const mcMovementState &goal) const
Definition: MotionCaptureMovement.cpp:160
operator<<
static std::ostream & operator<<(std::ostream &out, const mcMovementState &loc)
Definition: MotionCaptureMovement.h:31
MCEnvironment
Definition: MotionCaptureMovement.h:39
MCEnvironment::HCost
virtual double HCost(const mcMovementState &node1, const mcMovementState &node2) const
Heuristic value between two arbitrary nodes.
Definition: MotionCaptureMovement.cpp:143
MCEnvironment::GetOpenGLCoord
bool GetOpenGLCoord(float x_, float y_, GLdouble &x, GLdouble &y, GLdouble &z, GLdouble &radius) const
Definition: MotionCaptureMovement.cpp:311
operator==
static bool operator==(const mcMovementState &l1, const mcMovementState &l2)
Definition: MotionCaptureMovement.h:23
MCEnvironment::GCost
virtual double GCost(const mcMovementState &node1, const mcMovementState &node2) const
Definition: MotionCaptureMovement.cpp:148
SearchEnvironment
Definition: SearchEnvironment.h:30
MCEnvironment::distance
double distance(const mcMovementState &n1, const mcMovementState &n2) const
Definition: MotionCaptureMovement.cpp:178
node
Nodes to be stored within a Graph.
Definition: Graph.h:170
SearchEnvironment.h
MCEnvironment::MCEnvironment
MCEnvironment()
Definition: MotionCaptureMovement.h:42