Overseer
Region.h
1 #ifndef _OVERSEER_REGION_H_
2 #define _OVERSEER_REGION_H_
3 
4 #include <vector>
5 #include <queue>
6 #include <map>
7 #include <memory>
8 #include <iostream>
9 #include <algorithm>
10 
11 #include "spatial/box_multimap.hpp"
12 #include "spatial/neighbor_iterator.hpp"
13 #include "spatial/ordered_iterator.hpp"
14 #include "sc2api/sc2_api.h"
15 #include "Tile.h"
16 #include "Region.h"
17 
18 namespace Overseer{
19 
20  // class RegionEdge;
21 
22  typedef std::pair<sc2::Point2D, std::shared_ptr<Tile>> TilePosition;
23  typedef std::pair<sc2::Point2D, sc2::Unit *> UnitPosition;
24  typedef std::pair<sc2::Point2D, sc2::Point2D> PointPair;
25 
31  bool operator()(const PointPair &l, const PointPair &r) const;
32  };
33 
39  struct GreaterTile {
40  bool operator()(std::shared_ptr<TilePosition> &a, std::shared_ptr<TilePosition> &b) const;
41  };
42 
48  bool operator()(TilePosition &a, TilePosition &b) const;
49  };
50 
51 
57  enum EdgeType {
58  cliff,
59  impassible
60  };
61 
67  class Region {
68  public:
69 
73  Region();
74 
81  Region(size_t regionId, std::shared_ptr<TilePosition> tilePosition);
82 
88  size_t getArea() const;
89 
95  // std::vector<RegionEdge> getEdges();
96 
102  const std::vector<UnitPosition> getNeutralUnitPositions();
103 
109  size_t getId() const;
110 
116  void setId(size_t regionId);
117 
123  std::vector<TilePosition> getTilePositions() const;
124 
130  std::vector<sc2::Point2D> getPoints() const;
131 
137  void addTilePosition(std::shared_ptr<TilePosition> tilePosition);
138 
144  void addTilePosition(TilePosition& tilePosition);
145 
151  double getLargestDistanceToUnpathable() const;
152 
158  sc2::Point2D getMidPoint() const;
159 
165  void merge(Region region);
166 
170  void clear();
171 
172  private:
173  std::vector<TilePosition> m_tilePositions;
174  // std::vector<RegionEdge> m_edges;
175  std::vector<UnitPosition> m_neutralUnitPositions;
176 
177  sc2::Point2D m_midPoint;
178 
179  std::map<PointPair, float, ComparePointPairs> m_pointDistances;
180 
181  float m_largestDistUnpathable;
182  size_t m_id;
183  };
184 
185 
186  // TODO: Implement region edge.
191  // class RegionEdge {
192  // public:
193  // //Returns the regions this edge separates
194  // const std::pair<const Region *, const Region *> & getRegions(){return m_regions;}
195  // const std::vector<TilePosition> getPoints(){return m_points;}
196  // EdgeType getEdgeType(){return m_edgeType;}
197  // private:
198  // std::pair<const Region *, const Region *> m_regions;
199  // std::vector<TilePosition> m_points;
200  // EdgeType m_edgeType;
201  // };
202 }
203 
204 #endif /* _OVERSEER_REGION_H_ */
Definition: ChokePoint.cpp:3
sort on distance to nerearest unpathable.
Definition: Region.h:47
Check if two PointPairs are equal.
Definition: Region.h:30
A region handler.
Definition: Region.h:67
sort on distance to nerearest unpathable.
Definition: Region.h:39