17 #include <torchcraft/constants.h> 18 #include <torchcraft/frame.h> 19 #include <torchcraft/refcount.h> 24 struct HandshakeServer;
29 enum class FrameOrFrameDiff : uint8_t;
53 BW::Race race = BW::Race::Unknown;
90 int screen_position[2];
93 int visibility_size[2];
116 std::unordered_map<int32_t, std::vector<Unit>>
units;
120 uint64_t numUpdates = 0;
123 bool microBattles =
false,
124 std::set<BW::UnitType> onlyConsiderTypes = std::set<BW::UnitType>());
132 return microBattles_;
135 return onlyConsiderTypes_;
138 microBattles_ = microBattles;
141 onlyConsiderTypes_ = std::move(types);
142 aliveUnitsConsidered.clear();
146 std::vector<std::string> update(
const fbs::HandshakeServer* handshake);
147 std::vector<std::string> update(
const fbs::StateUpdate* stateUpdate);
148 std::vector<std::string> update(
const fbs::EndGame* end);
149 std::vector<std::string> update(
const fbs::PlayerLeft* left);
150 void trackAliveUnits(
151 std::vector<std::string>& upd,
152 const std::set<BW::UnitType>& considered);
155 if (!(frame->
resources[player_id].upgrades & (1ll << ut))) {
158 auto constexpr NB_LVLABLE_UPGRADES = 16;
159 if (ut >= NB_LVLABLE_UPGRADES) {
162 uint64_t lvls = frame->
resources[player_id].upgrades_level;
163 if (lvls & (1ll << ut)) {
166 if (lvls & (1ll << (ut + NB_LVLABLE_UPGRADES))) {
173 if (frame->
resources[player_id].techs & (1ll << tt)) {
180 bool setRawImage(
const fbs::StateUpdate* frame);
182 void postUpdate(std::vector<std::string>& upd);
183 bool checkBattleFinished(std::vector<std::string>& upd);
184 bool update_frame(
const void* flatBuffer,
const fbs::FrameOrFrameDiff type);
187 std::set<BW::UnitType> onlyConsiderTypes_;
std::vector< uint8_t > image
Definition: state.h:94
int getUpgradeLevel(BW::UpgradeType ut)
Definition: state.h:154
Copyright (c) 2015-present, Facebook, Inc.
Definition: openbwprocess.h:17
std::vector< uint8_t > walkable_data
Definition: state.h:63
bool has_left
Definition: state.h:56
std::string name
Definition: state.h:54
int lag_frames
Definition: state.h:60
std::string map_title
Definition: state.h:66
int frame_from_bwapi
Definition: state.h:76
bool game_ended
Definition: state.h:79
std::map< int, PlayerInfo > player_info
Definition: state.h:68
bool game_won
Definition: state.h:80
std::vector< Position > start_locations
Definition: state.h:67
std::unordered_map< int32_t, int32_t > aliveUnits
Definition: state.h:103
std::vector< uint8_t > ground_height_data
Definition: state.h:62
bool microBattles() const
Definition: state.h:131
replayer::Unit Unit
Definition: state.h:36
Position()
Definition: state.h:47
std::unordered_map< int32_t, Resources > resources
Definition: frame.h:311
std::string img_mode
Definition: state.h:89
bool hasResearched(BW::TechType tt)
Definition: state.h:172
Frame * frame
Definition: state.h:74
int player_id
Definition: state.h:69
replayer::Order Order
Definition: state.h:37
replayer::Frame Frame
Definition: state.h:41
replayer::Bullet Bullet
Definition: state.h:39
void setOnlyConsiderTypes(std::set< BW::UnitType > types)
Definition: state.h:140
bool replay
Definition: state.h:71
Copyright (c) 2015-present, Facebook, Inc.
Definition: refcount.h:23
bool waiting_for_restart
Definition: state.h:85
std::vector< uint8_t > visibility
Definition: state.h:92
int y
Definition: state.h:46
int battle_frame_count
Definition: state.h:77
std::string map_name
Definition: state.h:65
bool is_enemy
Definition: state.h:55
std::unordered_map< int32_t, int32_t > aliveUnitsConsidered
Definition: state.h:107
std::vector< int > deaths
Definition: state.h:75
int id
Definition: state.h:52
bool battle_just_ended
Definition: state.h:83
int last_battle_ended
Definition: state.h:86
std::vector< uint8_t > buildable_data
Definition: state.h:64
bool battle_won
Definition: state.h:84
std::unordered_map< int32_t, std::vector< Unit > > units
Definition: state.h:116
Position(int x, int y)
Definition: state.h:48
const std::set< BW::UnitType > & onlyConsiderTypes() const
Definition: state.h:134
void setMicroBattles(bool microBattles)
Definition: state.h:137
replayer::Action Action
Definition: state.h:40
int neutral_id
Definition: state.h:70