Overseer
Map.h
1 #ifndef _OVERSEER_MAP_H_
2 #define _OVERSEER_MAP_H_
3 
4 #include "Region.h"
5 #include "spatial/box_multimap.hpp"
6 #include "spatial/neighbor_iterator.hpp"
7 #include "spatial/ordered_iterator.hpp"
8 
9 
10 namespace Overseer{
11  typedef spatial::box_multimap<2, sc2::Point2D, std::shared_ptr<Tile>, spatial::accessor_less<accessors::point2d_accessor, sc2::Point2D>> TilePositionContainer;
12  typedef spatial::box_multimap<2, sc2::Point2D, sc2::Unit*, spatial::accessor_less<accessors::point2d_accessor, sc2::Point2D>> UnitPositionContainer;
13  typedef std::map<size_t, std::shared_ptr<Region>> RegionMap;
14  typedef std::map<std::pair<size_t,size_t>, std::vector<TilePosition>> RawFrontier;
15 
16  class Graph;
17 
22  class Map {
23  public:
24 
28  Map();
29 
35  Map(sc2::Agent* bot);
36 
42  size_t getHeight() const;
43 
49  size_t getWidth() const;
50 
56  std::vector<std::shared_ptr<Region>> getRegions();
57 
64  Region* getRegion(size_t id) ;
65 
72  const Region* getNearestRegion(sc2::Point2D pos) ;
73 
80  void addTile(sc2::Point2D& pos, std::shared_ptr<Tile> tile);
81 
87  bool valid(sc2::Point2D pos) const;
88 
95  TilePosition getClosestTilePosition(sc2::Point2D pos) const;
96 
102  void addRegion(Region region);
103 
110  std::shared_ptr<Tile> getTile(sc2::Point2D pos);
111 
117  size_t size() const;
118 
124  TilePositionContainer getTilePositions() const;
125 
131  std::vector<TilePosition> getXelNagas();
132 
138  std::vector<TilePosition> getMinerals();
139 
145  std::vector<TilePosition> getGeysers();
146 
152  std::vector<TilePosition> getDestructibles();
153 
159  void setBot(sc2::Agent* bot);
160 
166  std::vector<std::shared_ptr<TilePosition>> getFrontierPositions() const;
167 
173  RawFrontier getRawFrontier() const;
174 
180  sc2::Agent* getBot() const { return m_bot; }
181 
182  protected:
183 
184  std::pair<size_t, size_t> findNeighboringRegions(std::shared_ptr<TilePosition> tilePosition);
185 
186  sc2::Agent* m_bot;
187  static std::unique_ptr<Map> m_gInstance;
188 
189  UnitPositionContainer m_unitPositions;
190  TilePositionContainer m_tilePositions;
191  std::vector<std::shared_ptr<TilePosition>> m_buildableTiles;
192  RegionMap m_regions;
193  std::vector<std::shared_ptr<TilePosition>> m_frontierPositions;
194  RawFrontier m_rawFrontier;
195 
196  sc2::Point2D m_maxPlayable;
197  sc2::Point2D m_minPlayable;
198  sc2::Point2D m_centerPlayable;
199 
200  size_t m_width;
201  size_t m_height;
202  };
203 
204 }
205 
206 #endif /* _OVERSEER_MAP_H_ */
const Region * getNearestRegion(sc2::Point2D pos)
Gets closest region to a specific point.
Definition: Map.cpp:40
std::vector< TilePosition > getGeysers()
Get all tilePosition for Geysers.
Definition: Map.cpp:115
std::vector< TilePosition > getXelNagas()
Get all tilePosition for Xel&#39;nagas watch towers.
Definition: Map.cpp:103
size_t getWidth() const
Gets the map width.
Definition: Map.cpp:23
RawFrontier getRawFrontier() const
region pair and frontier map.
Definition: Map.cpp:98
void addRegion(Region region)
Apends a region to the container.
Definition: Map.cpp:69
std::shared_ptr< Tile > getTile(sc2::Point2D pos)
Gets a tile based on the position.
Definition: Map.cpp:73
Definition: ChokePoint.cpp:3
std::vector< std::shared_ptr< TilePosition > > getFrontierPositions() const
Get tiles that is between two regions.
Definition: Map.cpp:93
Map()
Simple default constructor does no initzalation.
Definition: Map.cpp:10
std::vector< TilePosition > getMinerals()
Get all tilePosition for Minerals.
Definition: Map.cpp:127
void addTile(sc2::Point2D &pos, std::shared_ptr< Tile > tile)
Apends a tile to container.
Definition: Map.cpp:53
A region handler.
Definition: Region.h:67
is the overseer map that holds the most "important" functionality for a outside user.
Definition: Map.h:22
std::vector< std::shared_ptr< Region > > getRegions()
Gets all the regions found.
Definition: Map.cpp:28
size_t size() const
Gets the size of the tile position container.
Definition: Map.cpp:77
size_t getHeight() const
Definition: Map.cpp:18
sc2::Agent * getBot() const
Gets the set agent.
Definition: Map.h:180
std::vector< TilePosition > getDestructibles()
Get tilePositions for Destructible objects.
Definition: Map.cpp:139
TilePositionContainer getTilePositions() const
Get all tile positions.
Definition: Map.cpp:82
void setBot(sc2::Agent *bot)
set the bot into overseer
Definition: Map.cpp:87
bool valid(sc2::Point2D pos) const
Check if a position is on map.
Definition: Map.cpp:57
TilePosition getClosestTilePosition(sc2::Point2D pos) const
Get the closest tile position.
Definition: Map.cpp:62
Region * getRegion(size_t id)
Get a specific region.
Definition: Map.cpp:38