TorchCraftAI
A bot for machine learning research on StarCraft: Brood War
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
cherrypi::ScenarioProvider Class Referenceabstract

Base class for providing scenarios. More...

#include <scenarioprovider.h>

Inherited by cherrypi::MicroScenarioProvider.

Public Member Functions

virtual ~ScenarioProvider ()=default
 
ScenarioProvidersetMaxFrames (int value)
 The maximum number of steps to play before considering a scenario finished Defaults to -1, which indicates no maximum. More...
 
ScenarioProvidersetGui (bool value)
 Specifies whether to run OpenBW headfully. More...
 
virtual std::pair< std::shared_ptr< BasePlayer >, std::shared_ptr< BasePlayer > > startNewScenario (const std::function< void(BasePlayer *)> &setup1, const std::function< void(BasePlayer *)> &setup2)=0
 Spawns a scenario. More...
 
virtual bool isFinished (int currentStep)
 Check whether the scenario is finished. More...
 

Protected Member Functions

template<typename TPlayer >
void loadMap (std::string const &map, tc::BW::Race race1, tc::BW::Race race2, GameType gameType, std::string const &replayPath=std::string())
 

Protected Attributes

int maxFrame_ = 24 * 60 * 60 * 2
 
bool gui_ = false
 
std::shared_ptr< BasePlayerplayer1_
 
std::shared_ptr< BasePlayerplayer2_
 
std::shared_ptr< GameMultiPlayergame_
 

Detailed Description

Base class for providing scenarios.

Returns a pair of players to be used by the training code.

Detects game end and cleans up after the scenario.

Constructor & Destructor Documentation

virtual cherrypi::ScenarioProvider::~ScenarioProvider ( )
virtualdefault

Member Function Documentation

bool cherrypi::ScenarioProvider::isFinished ( int  currentStep)
virtual

Check whether the scenario is finished.

By default, return true whenever the number of frames is exceeded or one of the players don't have any units left

template<typename TPlayer >
void cherrypi::ScenarioProvider::loadMap ( std::string const &  map,
tc::BW::Race  race1,
tc::BW::Race  race2,
GameType  gameType,
std::string const &  replayPath = std::string() 
)
inlineprotected
ScenarioProvider& cherrypi::ScenarioProvider::setGui ( bool  value)
inline

Specifies whether to run OpenBW headfully.

Takes effect only when spawning a new OpenBWProcess; so generally you want to invoke this before using the ScenarioProvider.

ScenarioProvider& cherrypi::ScenarioProvider::setMaxFrames ( int  value)
inline

The maximum number of steps to play before considering a scenario finished Defaults to -1, which indicates no maximum.

virtual std::pair<std::shared_ptr<BasePlayer>, std::shared_ptr<BasePlayer> > cherrypi::ScenarioProvider::startNewScenario ( const std::function< void(BasePlayer *)> &  setup1,
const std::function< void(BasePlayer *)> &  setup2 
)
pure virtual

Spawns a scenario.

It takes as parameters the setup functions for both players (this should take care of adding modules), and returns the pointers to the created players

Implemented in cherrypi::MicroScenarioProvider.

Member Data Documentation

std::shared_ptr<GameMultiPlayer> cherrypi::ScenarioProvider::game_
protected
bool cherrypi::ScenarioProvider::gui_ = false
protected
int cherrypi::ScenarioProvider::maxFrame_ = 24 * 60 * 60 * 2
protected
std::shared_ptr<BasePlayer> cherrypi::ScenarioProvider::player1_
protected
std::shared_ptr<BasePlayer> cherrypi::ScenarioProvider::player2_
protected

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