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

Generates Random armies. More...

#include <microscenarioproviderrandom.h>

Inherits cherrypi::MicroScenarioProvider.

Public Member Functions

 MicroScenarioProviderRandom (std::vector< tc::BW::Race > allowedRaces={tc::BW::Race::Protoss, tc::BW::Race::Terran, tc::BW::Race::Zerg}, bool randomSize=true, std::map< tc::BW::Race, int > maxSupplyMap={{tc::BW::Race::Protoss, 60},{tc::BW::Race::Terran, 55},{tc::BW::Race::Zerg, 50}}, bool checkCompatibility=true)
 
void setParams (std::vector< tc::BW::Race > allowedRaces, bool randomSize, std::map< tc::BW::Race, int > maxSupplyMap, bool checkCompatibility)
 
- Public Member Functions inherited from cherrypi::MicroScenarioProvider
virtual ~MicroScenarioProvider ()=default
 
void setReplay (std::string const &path)
 
std::pair< std::shared_ptr< BasePlayer >, std::shared_ptr< BasePlayer > > startNewScenario (const std::function< void(BasePlayer *)> &setup1, const std::function< void(BasePlayer *)> &setup2) override
 Spawns a scenario. More...
 
void endScenario ()
 
std::unique_ptr< RewardgetReward () const
 
void setMapPathPrefix (const std::string &)
 It's possible to run this from not the rootdir of the repository, in which case you can set the mapPathPrefix to where the maps should be found. More...
 
- Public Member Functions inherited from cherrypi::ScenarioProvider
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 bool isFinished (int currentStep)
 Check whether the scenario is finished. More...
 

Protected Member Functions

FixedScenario getFixedScenario () override
 
- Protected Member Functions inherited from cherrypi::MicroScenarioProvider
void endGame ()
 
void killAllUnits ()
 
void createNewGame ()
 
void createNewPlayers ()
 
void setupScenario ()
 
bool launchedWithReplay ()
 
MicroPlayermicroPlayer1 ()
 
MicroPlayermicroPlayer2 ()
 
- Protected Member Functions inherited from cherrypi::ScenarioProvider
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

std::vector< tc::BW::Race > allowedRaces_
 
bool randomSize_
 
std::map< tc::BW::Race, int > maxSupplyMap_
 
bool checkCompatibility_
 
- Protected Attributes inherited from cherrypi::MicroScenarioProvider
std::shared_ptr< tc::Clientclient1_
 
std::shared_ptr< tc::Clientclient2_
 
std::string replay_
 
std::string mapPathPrefix_
 
FixedScenario scenarioNow_
 
int unitsThisGame_ = 0
 
int unitsTotal_ = 0
 
int unitsSeenTotal_ = 0
 
int scenarioCount_ = 0
 
int resetCount_ = 0
 
- Protected Attributes inherited from cherrypi::ScenarioProvider
int maxFrame_ = 24 * 60 * 60 * 2
 
bool gui_ = false
 
std::shared_ptr< BasePlayerplayer1_
 
std::shared_ptr< BasePlayerplayer2_
 
std::shared_ptr< GameMultiPlayergame_
 

Detailed Description

Generates Random armies.

Parameters: AllowedRaces: the set of races we can randomly draw from maxSupplyMap: Maximum supply for each race. randomSize: if true, the target supply is drawn uniformly in [min(10, maxSupply), maxSupply]. Else, the target supply is the one from the supplyMap. checkCompatiblity: if true, we don't sample armies that are incompatible. Sources of incompatiblilites: air units in one army but no air weapon in the other, ground units in one army but no ground weapon in the other, cloaked/burrowable units in one army but no detector in the other. In other words, we require that each unit can be attacked by at least one unit of the other army.

Note that due to sampling artifacts, the actual sampled supply might be a bit smaller than the target

The default parameters give scenarios that are somewhat balanced (as mesured by playing random battles using attack-closest heuristic and no micro). Protoss has a slightly lower win-rate on average, around 30%.

The following units are currently left out:

Constructor & Destructor Documentation

cherrypi::MicroScenarioProviderRandom::MicroScenarioProviderRandom ( std::vector< tc::BW::Race >  allowedRaces = {tc::BW::Race::Protoss, tc::BW::Race::Terran, tc::BW::Race::Zerg},
bool  randomSize = true,
std::map< tc::BW::Race, int >  maxSupplyMap = {{tc::BW::Race::Protoss, 60}, {tc::BW::Race::Terran, 55}, {tc::BW::Race::Zerg, 50}},
bool  checkCompatibility = true 
)

Member Function Documentation

FixedScenario cherrypi::MicroScenarioProviderRandom::getFixedScenario ( )
overrideprotectedvirtual
void cherrypi::MicroScenarioProviderRandom::setParams ( std::vector< tc::BW::Race >  allowedRaces,
bool  randomSize,
std::map< tc::BW::Race, int >  maxSupplyMap,
bool  checkCompatibility 
)

Member Data Documentation

std::vector<tc::BW::Race> cherrypi::MicroScenarioProviderRandom::allowedRaces_
protected
bool cherrypi::MicroScenarioProviderRandom::checkCompatibility_
protected
std::map<tc::BW::Race, int> cherrypi::MicroScenarioProviderRandom::maxSupplyMap_
protected
bool cherrypi::MicroScenarioProviderRandom::randomSize_
protected

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