17 #include <torchcraft/frame.h> 18 #include <torchcraft/refcount.h> 19 #include <torchcraft/state.h> 31 std::vector<Frame*> frames;
32 std::unordered_map<int32_t, int32_t> numUnits;
41 for (
auto f : frames) {
48 if (i >= frames.size())
53 auto new_frame =
new Frame(f);
54 frames.push_back(new_frame);
57 keyframe = x < 0 ? frames.size() + 1 : (uint32_t)x;
73 for (
const auto f : frames) {
74 for (
auto u : f->units) {
75 auto s = u.second.size();
77 if (numUnits.count(i) == 0) {
79 }
else if (s > static_cast<size_t>(numUnits[i])) {
87 if (numUnits.find(key) == numUnits.end())
89 return numUnits.at(key);
97 std::vector<uint8_t>
const& walkability,
98 std::vector<uint8_t>
const& ground_height,
99 std::vector<uint8_t>
const& buildability,
100 std::vector<int>
const& start_loc_x,
101 std::vector<int>
const& start_loc_y);
106 uint8_t
const*
const walkability,
107 uint8_t
const*
const ground_height,
108 uint8_t
const*
const buildability,
109 std::vector<int>
const& start_loc_x,
110 std::vector<int>
const& start_loc_y);
112 void setRawMap(uint32_t h, uint32_t w, uint8_t
const* d) {
114 map.
data.resize(h * w);
115 map.
data.assign(d, d + h * w);
124 std::pair<int32_t, int32_t> getMap(
125 std::vector<uint8_t>& walkability,
126 std::vector<uint8_t>& ground_height,
127 std::vector<uint8_t>& buildability,
128 std::vector<int>& start_loc_x,
129 std::vector<int>& start_loc_y)
const;
134 void load(
const std::string& path);
135 void save(
const std::string& path,
bool compressed =
false);
void setNumUnits()
Definition: replayer.h:72
size_t size() const
Definition: replayer.h:62
Copyright (c) 2015-present, Facebook, Inc.
Definition: openbwprocess.h:17
int32_t mapWidth() const
Definition: replayer.h:68
int32_t getNumUnits(const int32_t &key) const
Definition: replayer.h:86
uint32_t getKeyFrame()
Definition: replayer.h:59
std::istream & operator>>(std::istream &in, Frame &o)
void setRawMap(uint32_t h, uint32_t w, uint8_t const *d)
Definition: replayer.h:112
std::ostream & operator<<(std::ostream &out, const Frame &o)
const std::vector< uint8_t > & getRawMap()
Definition: replayer.h:120
replayer::Frame Frame
Definition: state.h:41
Copyright (c) 2015-present, Facebook, Inc.
Definition: refcount.h:23
std::vector< uint8_t > data
Definition: replayer.h:26
~Replayer()
Definition: replayer.h:40
Frame * getFrame(size_t i)
Definition: replayer.h:47
void push(Frame *f)
Definition: replayer.h:52
Definition: replayer.h:29
uint32_t height
Definition: replayer.h:25
int32_t mapHeight() const
Definition: replayer.h:65
uint32_t width
Definition: replayer.h:25
void setKeyFrame(int32_t x)
Definition: replayer.h:56
Definition: replayer.h:24