TorchCraftAI
A bot for machine learning research on StarCraft: Brood War
Public Member Functions | List of all members
cherrypi::Player Class Reference

The main bot object for complete games of StarCraft. More...

#include <player.h>

Inherits cherrypi::BasePlayer.

Public Member Functions

 Player (std::shared_ptr< tc::Client > client)
 
 Player (const Player &)=delete
 
Playeroperator= (const Player &)=delete
 
void setFrameskip (int n)
 UI update frequency of Broodwar instance. Set this before calling init(). More...
 
void setCombineFrames (int n)
 Combine n server-side frames before taking any action. More...
 
void setNonBlocking (bool nonBlocking)
 Run bot step in separate thread to prevent blocking game execution. More...
 
void setMapHack (bool on)
 
virtual void init () override
 
void run ()
 
- Public Member Functions inherited from cherrypi::BasePlayer
 BasePlayer (std::shared_ptr< tc::Client > client)
 
virtual ~BasePlayer ()
 
 BasePlayer (const BasePlayer &)=delete
 
BasePlayeroperator= (const BasePlayer &)=delete
 
Statestate ()
 
std::shared_ptr< ModulegetTopModule () const
 
void addModule (std::shared_ptr< Module > module)
 
void addModules (std::vector< std::shared_ptr< Module >> const &modules)
 
template<typename T >
std::shared_ptr< T > findModule ()
 
void queueCmds (const std::vector< tc::Client::Command > &cmds)
 Add some commands to the queue, they will be executed on next step() More...
 
void setWarnIfSlow (bool warn)
 Log a warning if step() exceeds a maximum duration. More...
 
void setRealtimeFactor (float factor)
 Delay step() to make the game run in approx. factor*fastest speed. More...
 
void setCheckConsistency (bool check)
 Set whether to perform consistency checks during the game. More...
 
void setCollectTimers (bool collect)
 Set whether to gather timing statistics during the game. More...
 
void setLogFailedCommands (bool log)
 Set whether to log failed commands (via VLOG(0)). More...
 
void setDraw (bool draw)
 Set whether to post drawing commands (if any are posted). More...
 
virtual void stepModule (std::shared_ptr< Module > module)
 
void stepModules ()
 
void step ()
 
size_t steps () const
 
void leave ()
 
void dumpTraceAlongReplay (std::string const &replayFile)
 

Additional Inherited Members

- Protected Types inherited from cherrypi::BasePlayer
using commandStartEndFrame = std::pair< tc::BW::UnitCommandType, std::pair< FrameNum, FrameNum >>
 
- Protected Member Functions inherited from cherrypi::BasePlayer
virtual void preStep ()
 
virtual void postStep ()
 
void logFailedCommands ()
 
ClientCommands doStep ()
 Do the actual per-step work. More...
 
- Protected Attributes inherited from cherrypi::BasePlayer
std::shared_ptr< tc::Clientclient_
 
int frameskip_ = 1
 
int combineFrames_ = 3
 
bool warnIfSlow_ = false
 
bool nonBlocking_ = false
 
bool checkConsistency_ = false
 
bool collectTimers_ = false
 
bool logFailedCommands_ = false
 
int lastFrameStepped_ = 0
 
int framesDropped_ = 0
 
float realtimeFactor_ = -1.0f
 
std::vector< std::shared_ptr< Module > > modules_
 
Statestate_
 
std::shared_ptr< Moduletop_
 
std::unordered_map< std::shared_ptr< Module >, DurationmoduleTimeSpent_
 
std::unordered_map< std::shared_ptr< Module >, DurationmoduleTimeSpentAgg_
 
Duration stateUpdateTimeSpent_
 
Duration stateUpdateTimeSpentAgg_
 
size_t steps_ = 0
 
bool initialized_ = false
 
bool firstStepDone_ = false
 
hires_clock::time_point lastStep_
 
bool draw_ = true
 
std::vector< tc::Client::Command > pendingCmds_
 
- Static Protected Attributes inherited from cherrypi::BasePlayer
static decltype(std::chrono::milliseconds(50)) const kMaxStepDuration
 
static decltype(std::chrono::seconds(9)) const kMaxInitialStepDuration
 
static decltype(std::chrono::milliseconds(42)) const kStepDurationAtFastest
 

Detailed Description

The main bot object for complete games of StarCraft.

This class is used to play StarCraft Broodwar (TM) via the TorchCraft bridge. The behavior and actions of the player are determined by a user-supplied list of bot modules.

Constructor & Destructor Documentation

cherrypi::Player::Player ( std::shared_ptr< tc::Client client)
cherrypi::Player::Player ( const Player )
delete

Member Function Documentation

void cherrypi::Player::init ( )
overridevirtual

Reimplemented from cherrypi::BasePlayer.

Player& cherrypi::Player::operator= ( const Player )
delete
void cherrypi::Player::run ( )
void cherrypi::Player::setCombineFrames ( int  n)

Combine n server-side frames before taking any action.

Set this before calling init().

void cherrypi::Player::setFrameskip ( int  n)

UI update frequency of Broodwar instance. Set this before calling init().

void cherrypi::Player::setMapHack ( bool  on)
inline
void cherrypi::Player::setNonBlocking ( bool  nonBlocking)

Run bot step in separate thread to prevent blocking game execution.

Defaults to false.


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