13 #include "blackboard.h" 15 #include "tilesinfo.h" 17 #include "unitsinfo.h" 44 explicit State(std::shared_ptr<tc::Client> client);
50 std::unordered_map<int32_t, tc::Unit*>
const&
units()
const {
54 return units_.find(
id) == units_.end() ?
nullptr : units_.at(
id);
63 return (currentFrame_ * 42.0f) / 1000;
67 return tcstate_->lag_frames;
88 return tcstate_->map_name;
91 return tcstate_->map_title;
94 return Rect(0, 0, mapWidth_, mapHeight_);
106 template <
typename T,
typename... Args>
108 auto tracker = std::make_shared<T>(std::forward<Args>(args)...);
109 trackers_.emplace_back(tracker);
112 std::list<std::shared_ptr<Tracker>>
const&
trackers()
const {
126 std::vector<std::pair<std::string, std::chrono::milliseconds>>
128 std::vector<std::pair<std::string, std::chrono::milliseconds>>
130 for (
auto nameTime : stateUpdateTimeSpent_) {
131 auto ms = std::chrono::duration_cast<std::chrono::milliseconds>(
133 stateUpdateTimes.push_back(std::make_pair(nameTime.first, ms));
135 return stateUpdateTimes;
141 UpgradeLevel getUpgradeLevel(
const BuildType* upgrade)
const;
146 bool hasResearched(
const BuildType* tech)
const;
152 tc::BW::Race myRace()
const;
158 tc::BW::Race raceFromClient(
PlayerId playerId)
const;
163 bool gameEnded()
const;
174 void setCollectTimers(
bool collect);
194 typedef std::unordered_map<int, bool> Tech2StatusMap;
195 typedef std::unordered_map<int, UpgradeLevel> Upgrade2LevelMap;
197 void initTechnologyStatus();
198 void initUpgradeStatus();
200 void updateTechnologyStatus();
201 void updateUpgradeStatus();
202 void updateTrackers();
203 void updateFirstToLeave();
204 void findEnemyInfo();
206 std::shared_ptr<tc::Client> client_;
208 std::unordered_map<int32_t, tc::Unit*> units_;
210 std::unique_ptr<BWEM::Map> map_;
211 std::unique_ptr<tcbwapi::TCGame> tcbGame_;
214 std::list<std::shared_ptr<Tracker>> trackers_;
227 bool sawFirstEnemyUnit_ =
false;
228 bool collectTimers_ =
false;
230 Tech2StatusMap tech2StatusMap_;
231 Upgrade2LevelMap upgrade2LevelMap_;
233 std::vector<std::pair<std::string, Duration>> stateUpdateTimeSpent_;
235 bool mapHack_ =
false;
Game state.
Definition: state.h:42
AreaInfo * areaInfoPtr()
Definition: state.h:182
int FrameNum
Definition: basetypes.h:22
PlayerId playerId() const
Definition: state.h:70
TilesInfo * tilesInfoPtr()
Definition: state.h:179
Rect mapRect() const
Definition: state.h:93
FrameNum currentFrame() const
Definition: state.h:57
int mapHeight() const
Definition: state.h:84
UnitsInfo * unitsInfoPtr()
Definition: state.h:176
AreaInfo & areaInfo()
Definition: state.h:122
Represents and holds information about buildable types (units, upgrades, techs).
Definition: buildtype.h:36
std::vector< std::pair< std::string, std::chrono::milliseconds > > getStateUpdateTimes() const
Definition: state.h:127
std::list< std::shared_ptr< Tracker > > const & trackers() const
Definition: state.h:112
UnitsInfo & unitsInfo()
Definition: state.h:116
std::shared_ptr< T > addTracker(Args &&...args)
Definition: state.h:107
PlayerId neutralId() const
Definition: state.h:74
Map features from StaticData.
Updates and organizes information about all the units in the game.
Definition: unitsinfo.h:294
int mapWidth() const
Definition: state.h:81
const std::string mapName() const
Definition: state.h:87
tc::State * tcstate()
The underlying TorchCraft state.
Definition: state.h:170
Blackboard * board() const
Definition: state.h:99
An access-aware blackboard.
Definition: blackboard.h:88
int UpgradeLevel
Type to represent upgrade level values.
Definition: state.h:32
TilesInfo & tilesInfo()
Definition: state.h:119
Manages and updates per-tile data.
Definition: tilesinfo.h:81
tc::Unit * unit(int32_t id) const
Definition: state.h:53
const std::string mapTitle() const
Definition: state.h:90
float currentGameTime() const
Current game time in seconds, assuming "fastest" speed.
Definition: state.h:62
FrameNum latencyFrames() const
Definition: state.h:66
int PlayerId
Definition: basetypes.h:21
Definition: areainfo.h:17
void setMapHack(bool h)
Definition: state.h:186
std::unordered_map< int32_t, tc::Unit * > const & units() const
Definition: state.h:50
Main namespace for bot-related code.
Definition: areainfo.cpp:17
Access point for area and base information.
Definition: areainfo.h:112
bool mapHack()
Definition: state.h:189
BWEM::Map * map() const
Definition: state.h:102