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

A simple utility module that runs a user-supplied function once per game. More...

#include <once.h>

Inherits cherrypi::LambdaModule.

Public Member Functions

 OnceModule (StepFunctionState func, std::string name=std::string())
 
 OnceModule (StepFunctionStateModule func, std::string name=std::string())
 
virtual ~OnceModule ()=default
 
virtual void step (State *state) override
 
- Public Member Functions inherited from cherrypi::LambdaModule
 LambdaModule (StepFunctionState fn, std::string name=std::string())
 
 LambdaModule (StepFunctionStateModule fn, std::string name=std::string())
 
virtual ~LambdaModule ()=default
 
- Public Member Functions inherited from cherrypi::Module
virtual ~Module ()=default
 
virtual void setPlayer (BasePlayer *p)
 
void setName (std::string name)
 
std::string name ()
 
virtual void onGameStart (State *s)
 
virtual void onGameEnd (State *s)
 

Static Public Member Functions

static std::shared_ptr< ModulemakeWithSpawns (const std::vector< SpawnPosition > &spawns, std::string name=std::string())
 Spawns ally units. More...
 
static std::shared_ptr< ModulemakeWithEnemySpawns (const std::vector< SpawnPosition > &spawns, std::string name=std::string())
 Similar function for enemy units. More...
 
static std::vector< tc::Client::Command > makeSpawnCommands (const std::vector< SpawnPosition > &spawns, State *state, int playerId)
 Returns a list of commands which spawn units. More...
 
- 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)
 

Static Protected Member Functions

static LambdaModule::StepFunctionState makeSpawnFn (const std::vector< SpawnPosition > &spawns, bool enemy)
 Convenience function that returns a lambda to spawn units If enemy is true, then the units are spawned for the enemy. More...
 

Additional Inherited Members

- Public Types inherited from cherrypi::LambdaModule
using StepFunctionState = std::function< void(State *)>
 
using StepFunctionStateModule = std::function< void(State *, Module *)>
 
- Protected Member Functions inherited from cherrypi::Module
 Module ()
 
- Protected Attributes inherited from cherrypi::LambdaModule
mapbox::util::variant< StepFunctionState, StepFunctionStateModulefn_
 
- Protected Attributes inherited from cherrypi::Module
BasePlayerplayer_
 
std::string name_
 

Detailed Description

A simple utility module that runs a user-supplied function once per game.

Constructor & Destructor Documentation

cherrypi::OnceModule::OnceModule ( StepFunctionState  func,
std::string  name = std::string() 
)
cherrypi::OnceModule::OnceModule ( StepFunctionStateModule  func,
std::string  name = std::string() 
)
virtual cherrypi::OnceModule::~OnceModule ( )
virtualdefault

Member Function Documentation

std::vector< tc::Client::Command > cherrypi::OnceModule::makeSpawnCommands ( const std::vector< SpawnPosition > &  spawns,
State state,
int  playerId 
)
static

Returns a list of commands which spawn units.

LambdaModule::StepFunctionState cherrypi::OnceModule::makeSpawnFn ( const std::vector< SpawnPosition > &  spawns,
bool  enemy 
)
staticprotected

Convenience function that returns a lambda to spawn units If enemy is true, then the units are spawned for the enemy.

std::shared_ptr< Module > cherrypi::OnceModule::makeWithEnemySpawns ( const std::vector< SpawnPosition > &  spawns,
std::string  name = std::string() 
)
static

Similar function for enemy units.

std::shared_ptr< Module > cherrypi::OnceModule::makeWithSpawns ( const std::vector< SpawnPosition > &  spawns,
std::string  name = std::string() 
)
static

Spawns ally units.

void cherrypi::OnceModule::step ( State state)
overridevirtual

Reimplemented from cherrypi::LambdaModule.


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