TorchCraftAI
A bot for machine learning research on StarCraft: Brood War
Namespaces | Classes | Functions | Variables
torchcraft::replayer Namespace Reference

Namespaces

 detail
 

Classes

struct  Action
 
struct  Bullet
 
class  Frame
 
class  FrameDiff
 
struct  Map
 
struct  Order
 
class  Replayer
 
struct  Resources
 
struct  Unit
 
struct  UnitCommand
 

Functions

std::ostream & operator<< (std::ostream &out, const Frame &o)
 
std::istream & operator>> (std::istream &in, Frame &o)
 
std::ostream & operator<< (std::ostream &out, const FrameDiff &o)
 
std::istream & operator>> (std::istream &in, FrameDiff &o)
 
void writeTail (std::ostream &out, const std::unordered_map< int32_t, std::vector< replayer::Action >> &actions, const std::unordered_map< int32_t, replayer::Resources > &resources, const std::vector< replayer::Bullet > &bullets)
 
void readTail (std::istream &in, std::unordered_map< int32_t, std::vector< replayer::Action >> &actions, std::unordered_map< int32_t, replayer::Resources > &resources, std::vector< replayer::Bullet > &bullets)
 
FrameDiff frame_diff (Frame &, Frame &)
 
FrameDiff frame_diff (Frame *, Frame *)
 
Frameframe_undiff (FrameDiff *, Frame *)
 
Frameframe_undiff (Frame *, FrameDiff *)
 
void frame_undiff (Frame *result, FrameDiff *, Frame *)
 
void frame_undiff (Frame *result, Frame *, FrameDiff *)
 

Variables

const auto packActionsOfPlayer
 
const auto packResourcesOfPlayer
 
const auto packBullet
 
const auto unpackAction
 
const auto unpackResources
 
const auto unpackBullet
 

Function Documentation

FrameDiff torchcraft::replayer::frame_diff ( Frame ,
Frame  
)
FrameDiff torchcraft::replayer::frame_diff ( Frame ,
Frame  
)
Frame* torchcraft::replayer::frame_undiff ( FrameDiff ,
Frame  
)
Frame* torchcraft::replayer::frame_undiff ( Frame ,
FrameDiff  
)
void torchcraft::replayer::frame_undiff ( Frame result,
FrameDiff ,
Frame  
)
void torchcraft::replayer::frame_undiff ( Frame result,
Frame ,
FrameDiff  
)
std::ostream& torchcraft::replayer::operator<< ( std::ostream &  out,
const Frame o 
)
std::ostream& torchcraft::replayer::operator<< ( std::ostream &  out,
const FrameDiff o 
)
std::istream& torchcraft::replayer::operator>> ( std::istream &  in,
Frame o 
)
std::istream& torchcraft::replayer::operator>> ( std::istream &  in,
FrameDiff o 
)
void torchcraft::replayer::readTail ( std::istream &  in,
std::unordered_map< int32_t, std::vector< replayer::Action >> &  actions,
std::unordered_map< int32_t, replayer::Resources > &  resources,
std::vector< replayer::Bullet > &  bullets 
)
void torchcraft::replayer::writeTail ( std::ostream &  out,
const std::unordered_map< int32_t, std::vector< replayer::Action >> &  actions,
const std::unordered_map< int32_t, replayer::Resources > &  resources,
const std::vector< replayer::Bullet > &  bullets 
)

Variable Documentation

const auto torchcraft::replayer::packActionsOfPlayer
Initial value:
= [](flatbuffers::FlatBufferBuilder& builder) {
return [&builder](const std::pair<int32_t, std::vector<Action>>& actionPair) {
auto packAction = [&builder](const Action& action) {
auto actionsOffset = builder.CreateVector(action.action);
builder.Finish(actionsOffset);
fbs::ActionBuilder fbsActionBuilder(builder);
fbsActionBuilder.add_action(actionsOffset);
fbsActionBuilder.add_uid(action.uid);
fbsActionBuilder.add_aid(action.aid);
auto output = fbsActionBuilder.Finish();
builder.Finish(output);
return output;
};
std::vector<flatbuffers::Offset<fbs::Action>> fbsActions(actionPair.second.size());
std::transform(actionPair.second.begin(), actionPair.second.end(), fbsActions.begin(), packAction);
auto actionOffsets = builder.CreateVector(fbsActions);
builder.Finish(actionOffsets);
fbs::ActionsOfPlayerBuilder fbsActionsOfPlayerBuilder(builder);
fbsActionsOfPlayerBuilder.add_playerId(actionPair.first);
fbsActionsOfPlayerBuilder.add_actions(actionOffsets);
auto output = fbsActionsOfPlayerBuilder.Finish();
builder.Finish(output);
return output;
};
}
replayer::Action Action
Definition: state.h:40
const auto torchcraft::replayer::packBullet
Initial value:
= [](const Bullet& bullet) {
return fbs::Bullet(bullet.type, bullet.x, bullet.y);
}
replayer::Bullet Bullet
Definition: state.h:39
const auto torchcraft::replayer::packResourcesOfPlayer
Initial value:
= [](flatbuffers::FlatBufferBuilder& builder) {
return [&builder](const std::pair<int32_t, Resources>& resourcesPair) {
auto resources = resourcesPair.second;
fbs::ResourcesBuilder fbsResourcesBuilder(builder);
fbsResourcesBuilder.add_ore(resources.ore);
fbsResourcesBuilder.add_gas(resources.gas);
fbsResourcesBuilder.add_used_psi(resources.used_psi);
fbsResourcesBuilder.add_total_psi(resources.total_psi);
fbsResourcesBuilder.add_upgrades(resources.upgrades);
fbsResourcesBuilder.add_upgrades_level(resources.upgrades_level);
fbsResourcesBuilder.add_techs(resources.techs);
auto fbsResources = fbsResourcesBuilder.Finish();
builder.Finish(fbsResources);
fbs::ResourcesOfPlayerBuilder fbsResourcesOfPlayerBuilder(builder);
fbsResourcesOfPlayerBuilder.add_playerId(resourcesPair.first);
fbsResourcesOfPlayerBuilder.add_resources(fbsResources);
auto output = fbsResourcesOfPlayerBuilder.Finish();
builder.Finish(output);
return output;
};
}
const auto torchcraft::replayer::unpackAction
Initial value:
= [](const fbs::Action* fbsAction) {
assert(fbsAction);
assert(fbsAction->action());
auto fbsActionInts = fbsAction->action();
Action action;
action.action.resize(fbsActionInts->size());
std::copy(fbsActionInts->begin(), fbsActionInts->end(), action.action.begin());
action.uid = fbsAction->uid();
action.aid = fbsAction->aid();
return action;
}
std::vector< int32_t > action
Definition: frame.h:49
replayer::Action Action
Definition: state.h:40
const auto torchcraft::replayer::unpackBullet
Initial value:
= [](const fbs::Bullet* fbsBullet) {
Bullet bullet;
bullet.type = fbsBullet->type();
bullet.x = fbsBullet->x();
bullet.y = fbsBullet->y();
return bullet;
}
int32_t type
Definition: frame.h:45
replayer::Bullet Bullet
Definition: state.h:39
const auto torchcraft::replayer::unpackResources
Initial value:
= [](const fbs::ResourcesOfPlayer* fbsResourcesOfPlayer) {
auto fbsResources = fbsResourcesOfPlayer->resources();
auto resources = std::make_pair(fbsResourcesOfPlayer->playerId(), Resources()) ;
resources.second.ore = fbsResources->ore();
resources.second.gas = fbsResources->gas();
resources.second.used_psi = fbsResources->used_psi();
resources.second.total_psi = fbsResources->total_psi();
resources.second.upgrades = fbsResources->upgrades();
resources.second.upgrades_level = fbsResources->upgrades_level();
resources.second.techs = fbsResources->techs();
return resources;
}
replayer::Resources Resources
Definition: state.h:38