HOG2
MapCliqueAbstraction.h
Go to the documentation of this file.
1 /*
2  * $Id: MapCliqueAbstraction.h
3  * hog2
4  *
5  * Created by Nathan Sturtevant on 6/3/05.
6  * Modified by Nathan Sturtevant on 02/29/20.
7  *
8  * This file is part of HOG2. See https://github.com/nathansttt/hog2 for licensing information.
9  *
10  */
11 
12 #include "MapAbstraction.h"
13 
14 #ifndef MAPCLIQUEABSTRACTION_H
15 #define MAPCLIQUEABSTRACTION_H
16 
21 class MapCliqueAbstraction : public MapAbstraction {
22 public:
23  MapCliqueAbstraction(Map *, bool uniform = true);
24  virtual ~MapCliqueAbstraction();
26  virtual MapAbstraction *Clone(Map *_m) { return new MapCliqueAbstraction(_m); }
27  virtual void VerifyHierarchy();
28 // virtual void draw();
29 // virtual void rebuild();
30 // virtual int GetRevision() { return 0; }
31 
32  bool Pathable(node *from, node *to);
33  bool Pathable(unsigned int from, unsigned int to);
34  //path *getQuickPath(node *from, node *to);
35  void GetNumAbstractGraphs(node *from, node *to, std::vector<node *> &fromChain, std::vector<node *> &toChain);
36  //node *GetNthParent(node *, int n);
37 
38  void ClearMarkedNodes();
39  void clearDisplayLists();
40 
41  // first step to allowing simple map adjustments...
42  virtual void RemoveNode(node *n);
43  void RemoveEdge(edge *e, unsigned int absLevel);
44  virtual void AddNode(node *n);
45  virtual void AddEdge(edge *e, unsigned int absLevel);
46  // this must be called after RemoveEdge, but RemoveNode will take care of itself
47  void RepairAbstraction();
49  edge *findEdgeParent(edge *e, unsigned int absLevel);
50 
51  int MeasureRepairHits();
52 // virtual int getNumPrimitiveActions() = 0;
53 // virtual node *getNodeForPrimitiveAction(node *, int) = 0;
54 protected:
55  virtual Graph *abstractGraph(Graph *g);
56  virtual Graph *cliqueAbstractGraph(Graph *g);
57  //virtual Graph *neighborAbstractGraph(Graph *g, int width = 1);
58  void addNodesToParent(Graph *g, node *n, node *parent, int width);
59  void addTunnel(node *n, Graph *g, node *newNode);
60  void renameNodeInAbstraction(node *which, unsigned int oldID);
61  int getChildGroups(node *which);
62  void splitNode(node *which, int numGroups);
63  void addNodeToRepairQ(node *n);
64  void removeNodeFromRepairQ(node *n);
65  //void removeDiagonalEdgesAroundNode(node *n);
66 
67  // helper functions for splitting nodes
68  void resetLocationCache(node *n);
69  void checkAndCreateParent(node *which);
70  void insertNodeIntoHierarchy(node *newNode);
71  //void transferNode(node *which, node *oldParent, node *newParent, int whichChild);
72  void transferGroup(int group, node *oldParent, node *newParent);
73  void abstractUpEdge(unsigned int absLevel, edge *e);
74  void extractGroupIntoNewNode(node *parent, int group);
75  void mergeGroupIntoNeighbor(node *parent, int group, node *neighbor = 0);
76  bool checkNeighborClique(node *child, node *neighbor);
77  node *findNeighborCliques(node *parent, int group);
79  int getGroupSize(node *parent, int group);
80  node *getNodeInGroup(node *parent, int group);
81 private:
82  void buildAbstractions();
83  void cleanMemory();
84 
85 #ifdef INSTRUMENT_REPAIR
86  std::vector<int> hit;
87 #endif
88  std::vector<GLuint> displayLists;
89  // temporary Q for nodes that are modified in the abstraction
90  // we can then process them for changes all at once.
91  std::vector<node *> modifiedNodeQ;
93 };
94 
95 #endif
MapCliqueAbstraction::checkAndCreateParent
void checkAndCreateParent(node *which)
Definition: MapCliqueAbstraction.cpp:1578
graphMove
Definition: GraphEnvironment.h:34
MapCliqueAbstraction::RemoveEdge
void RemoveEdge(edge *e, unsigned int absLevel)
Definition: MapCliqueAbstraction.cpp:978
MapCliqueAbstraction::getNodeInGroup
node * getNodeInGroup(node *parent, int group)
Definition: MapCliqueAbstraction.cpp:1295
MapCliqueAbstraction::renameNodeInAbstraction
void renameNodeInAbstraction(node *which, unsigned int oldID)
Definition: MapCliqueAbstraction.cpp:1801
MapCliqueAbstraction::cleanMemory
void cleanMemory()
Definition: MapCliqueAbstraction.cpp:172
MapCliqueAbstraction::abstractGraph
virtual Graph * abstractGraph(Graph *g)
Definition: MapCliqueAbstraction.cpp:217
MapCliqueAbstraction::addNodesToParent
void addNodesToParent(Graph *g, node *n, node *parent, int width)
Definition: MapCliqueAbstraction.cpp:265
width
int width
Definition: SFML_HOG.cpp:54
Graph
A generic Graph class.
Definition: Graph.h:66
MapCliqueAbstraction::VerifyHierarchy
virtual void VerifyHierarchy()
Definition: MapCliqueAbstraction.cpp:51
MapCliqueAbstraction::displayLists
std::vector< GLuint > displayLists
Definition: MapCliqueAbstraction.h:88
MapCliqueAbstraction::findNeighborCliques
node * findNeighborCliques(node *parent, int group)
Definition: MapCliqueAbstraction.cpp:1335
MapCliqueAbstraction::RepairAbstraction
void RepairAbstraction()
Definition: MapCliqueAbstraction.cpp:1109
MapCliqueAbstraction::~MapCliqueAbstraction
virtual ~MapCliqueAbstraction()
Definition: MapCliqueAbstraction.cpp:46
MapCliqueAbstraction::ClearMarkedNodes
void ClearMarkedNodes()
MapCliqueAbstraction::abstractUpEdge
void abstractUpEdge(unsigned int absLevel, edge *e)
Definition: MapCliqueAbstraction.cpp:1682
MapCliqueAbstraction::checkNeighborClique
bool checkNeighborClique(node *child, node *neighbor)
Definition: MapCliqueAbstraction.cpp:1381
MapCliqueAbstraction::findNodeParent
node * findNodeParent(node *n)
Definition: MapCliqueAbstraction.cpp:1759
MapCliqueAbstraction::splitNode
void splitNode(node *which, int numGroups)
Definition: MapCliqueAbstraction.cpp:1204
MapCliqueAbstraction::AddEdge
virtual void AddEdge(edge *e, unsigned int absLevel)
Definition: MapCliqueAbstraction.cpp:972
MapCliqueAbstraction::GetNumAbstractGraphs
void GetNumAbstractGraphs(node *from, node *to, std::vector< node * > &fromChain, std::vector< node * > &toChain)
MapCliqueAbstraction
A map abstraction based on the reduction of cliques.
Definition: MapCliqueAbstraction.h:21
MapCliqueAbstraction::MapCliqueAbstraction
MapCliqueAbstraction(Map *, bool uniform=true)
Construct a new Graph hierarchy.
Definition: MapCliqueAbstraction.cpp:36
MapCliqueAbstraction::RemoveNode
virtual void RemoveNode(node *n)
Definition: MapCliqueAbstraction.cpp:1037
MapCliqueAbstraction::transferGroup
void transferGroup(int group, node *oldParent, node *newParent)
Definition: MapCliqueAbstraction.cpp:1607
MapCliqueAbstraction::getChildGroups
int getChildGroups(node *which)
Definition: MapCliqueAbstraction.cpp:1146
MapCliqueAbstraction::cliqueAbstractGraph
virtual Graph * cliqueAbstractGraph(Graph *g)
Definition: MapCliqueAbstraction.cpp:289
MapCliqueAbstraction::modifiedNodeQ
std::vector< node * > modifiedNodeQ
Definition: MapCliqueAbstraction.h:91
MapCliqueAbstraction::Pathable
bool Pathable(node *from, node *to)
Definition: MapCliqueAbstraction.cpp:949
MapCliqueAbstraction::abstractUniformly
bool abstractUniformly
Definition: MapCliqueAbstraction.h:92
MapCliqueAbstraction::Clone
virtual MapAbstraction * Clone(Map *_m)
return a new abstraction map of the same type as this map abstraction
Definition: MapCliqueAbstraction.h:26
MapAbstraction.h
MapCliqueAbstraction::resetLocationCache
void resetLocationCache(node *n)
Definition: MapCliqueAbstraction.cpp:1726
MapCliqueAbstraction::extractGroupIntoNewNode
void extractGroupIntoNewNode(node *parent, int group)
Definition: MapCliqueAbstraction.cpp:1469
MapCliqueAbstraction::MeasureRepairHits
int MeasureRepairHits()
MeasureRepairHits Measure the number of levels hit during repair.
Definition: MapCliqueAbstraction.cpp:1842
MapCliqueAbstraction::addTunnel
void addTunnel(node *n, Graph *g, node *newNode)
Definition: MapCliqueAbstraction.cpp:921
MapCliqueAbstraction::mergeGroupIntoNeighbor
void mergeGroupIntoNeighbor(node *parent, int group, node *neighbor=0)
Definition: MapCliqueAbstraction.cpp:1415
MapCliqueAbstraction::AddNode
virtual void AddNode(node *n)
Definition: MapCliqueAbstraction.cpp:968
MapCliqueAbstraction::buildAbstractions
void buildAbstractions()
Definition: MapCliqueAbstraction.cpp:188
MapCliqueAbstraction::insertNodeIntoHierarchy
void insertNodeIntoHierarchy(node *newNode)
Definition: MapCliqueAbstraction.cpp:1496
MapCliqueAbstraction::removeNodeFromRepairQ
void removeNodeFromRepairQ(node *n)
Definition: MapCliqueAbstraction.cpp:1024
MapCliqueAbstraction::addNodeToRepairQ
void addNodeToRepairQ(node *n)
Definition: MapCliqueAbstraction.cpp:1006
node
Nodes to be stored within a Graph.
Definition: Graph.h:170
Map
A tile-based representation of the world.
Definition: Map.h:142
MapCliqueAbstraction::findEdgeParent
edge * findEdgeParent(edge *e, unsigned int absLevel)
Definition: MapCliqueAbstraction.cpp:1776
MapCliqueAbstraction::getGroupSize
int getGroupSize(node *parent, int group)
Definition: MapCliqueAbstraction.cpp:1314
edge
Edge class for connections between node in a Graph.
Definition: Graph.h:129
MapCliqueAbstraction::clearDisplayLists
void clearDisplayLists()
Definition: MapCliqueAbstraction.cpp:179