TorchCraftAI
A bot for machine learning research on StarCraft: Brood War
Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
cherrypi::CherryVisDumperModule Class Reference

Records bot internal state and dumps it to a file readable by CherryVis. More...

#include <cherryvisdumper.h>

Inherits cherrypi::Module.

Classes

class  Logger
 
struct  TraceData
 
struct  TreeData
 
class  TreeNode
 
struct  UnitData
 

Public Types

using Dumpable = std::variant< Unit *, Position, int, float, std::string >
 

Public Member Functions

virtual ~CherryVisDumperModule ()=default
 
void setReplayFile (std::string const &replayFile)
 
virtual void step (State *s) override
 
virtual void onGameStart (State *s) override
 
virtual void onGameEnd (State *s) override
 
LoggergetGlobalLogger ()
 
LoggergetUnitLogger (Unit *u)
 
void onDrawCommand (State *s, tc::Client::Command const &command)
 
template<typename T , typename V , typename W >
void addTree (State *s, std::string const &name, T dump_node, V get_children, W root)
 
void dumpTensorsSummary (State *s, std::unordered_map< std::string, ag::Variant > const &tensors)
 
void dumpTerrainHeatmaps (State *s, std::unordered_map< std::string, ag::Variant > const &tensors, std::array< int, 2 > const &topLeftPixel, std::array< float, 2 > const &scalingToPixels)
 Dumps a heatmap that can be displayed as overlay of the terrain. More...
 
void dumpGameValue (State *s, std::string const &key, float value)
 
- Public Member Functions inherited from cherrypi::Module
virtual ~Module ()=default
 
virtual void setPlayer (BasePlayer *p)
 
void setName (std::string name)
 
std::string name ()
 

Static Public Member Functions

static void writeGameSummary (State *final_state, std::string const &file)
 
static std::string parseReplayFileName (std::string name)
 
- Static Public Member Functions inherited from cherrypi::Module
template<typename T , typename... Args>
static std::shared_ptr< T > make (Args &&...args)
 
static std::shared_ptr< Modulemake (std::string const &typeName)
 
static std::string makeName (std::type_index const &type)
 

Protected Member Functions

int32_t getUnitTaskId (State *s, Unit *unit)
 
std::string getBoardValueAsString (Blackboard::Data const &value)
 
void dumpGameUpcs (State *s)
 
void writeTrees (std::string const &dumpDirectory)
 
void writeTensors (std::string const &dumpDirectory)
 
nlohmann::json getTensorSummary (std::string const &name, at::Tensor const &t)
 
nlohmann::json getTensor1d (at::Tensor const &t)
 
- Protected Member Functions inherited from cherrypi::Module
 Module ()
 

Protected Attributes

std::string replayFileName_
 
TraceData trace_
 
std::unique_ptr< CherryVisLogSinklogSink_
 
- Protected Attributes inherited from cherrypi::Module
BasePlayerplayer_
 
std::string name_
 

Detailed Description

Records bot internal state and dumps it to a file readable by CherryVis.

Member Typedef Documentation

using cherrypi::CherryVisDumperModule::Dumpable = std::variant<Unit*, Position, int, float, std::string>

Constructor & Destructor Documentation

virtual cherrypi::CherryVisDumperModule::~CherryVisDumperModule ( )
virtualdefault

Member Function Documentation

template<typename T , typename V , typename W >
void cherrypi::CherryVisDumperModule::addTree ( State s,
std::string const &  name,
dump_node,
get_children,
root 
)
void cherrypi::CherryVisDumperModule::dumpGameUpcs ( State s)
protected
void cherrypi::CherryVisDumperModule::dumpGameValue ( State s,
std::string const &  key,
float  value 
)
inline
void cherrypi::CherryVisDumperModule::dumpTensorsSummary ( State s,
std::unordered_map< std::string, ag::Variant > const &  tensors 
)
void cherrypi::CherryVisDumperModule::dumpTerrainHeatmaps ( State s,
std::unordered_map< std::string, ag::Variant > const &  tensors,
std::array< int, 2 > const &  topLeftPixel,
std::array< float, 2 > const &  scalingToPixels 
)

Dumps a heatmap that can be displayed as overlay of the terrain.

Parameters
std::string cherrypi::CherryVisDumperModule::getBoardValueAsString ( Blackboard::Data const &  value)
protected
Logger& cherrypi::CherryVisDumperModule::getGlobalLogger ( )
inline
nlohmann::json cherrypi::CherryVisDumperModule::getTensor1d ( at::Tensor const &  t)
protected
nlohmann::json cherrypi::CherryVisDumperModule::getTensorSummary ( std::string const &  name,
at::Tensor const &  t 
)
protected
Logger& cherrypi::CherryVisDumperModule::getUnitLogger ( Unit u)
inline
int32_t cherrypi::CherryVisDumperModule::getUnitTaskId ( State s,
Unit unit 
)
protected
void cherrypi::CherryVisDumperModule::onDrawCommand ( State s,
tc::Client::Command const &  command 
)
void cherrypi::CherryVisDumperModule::onGameEnd ( State s)
overridevirtual

Reimplemented from cherrypi::Module.

void cherrypi::CherryVisDumperModule::onGameStart ( State s)
overridevirtual

Reimplemented from cherrypi::Module.

std::string cherrypi::CherryVisDumperModule::parseReplayFileName ( std::string  name)
static
void cherrypi::CherryVisDumperModule::setReplayFile ( std::string const &  replayFile)
inline
void cherrypi::CherryVisDumperModule::step ( State s)
overridevirtual

Reimplemented from cherrypi::Module.

void cherrypi::CherryVisDumperModule::writeGameSummary ( State final_state,
std::string const &  file 
)
static
void cherrypi::CherryVisDumperModule::writeTensors ( std::string const &  dumpDirectory)
protected
void cherrypi::CherryVisDumperModule::writeTrees ( std::string const &  dumpDirectory)
protected

Member Data Documentation

std::unique_ptr<CherryVisLogSink> cherrypi::CherryVisDumperModule::logSink_
protected
std::string cherrypi::CherryVisDumperModule::replayFileName_
protected
TraceData cherrypi::CherryVisDumperModule::trace_
protected

The documentation for this class was generated from the following files: