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

Stores an unordered_map[GameUID] = unordered_map[int, Episode] All the public functions here should be autolocking and therefore relatively thread safe. More...

#include <trainer.h>

Public Types

using Episode = std::vector< std::shared_ptr< ReplayBufferFrame >>
 
using Store = std::unordered_map< GameUID, std::unordered_map< EpisodeKey, Episode >>
 
using UIDKeyStore = std::unordered_map< GameUID, std::unordered_set< EpisodeKey >>
 
using SampleOutput = std::pair< EpisodeTuple, std::reference_wrapper< Episode >>
 

Public Member Functions

Episodeappend (GameUID uid, EpisodeKey key, std::shared_ptr< ReplayBufferFrame > value, bool isDone=false)
 
std::size_t size () const
 
std::size_t size (GameUID const &) const
 
std::size_t sizeDone () const
 
std::size_t sizeDone (GameUID const &) const
 
void clear ()
 
void erase (GameUID const &, EpisodeKey const &=kDefaultEpisodeKey)
 
std::vector< SampleOutputgetAllEpisodes ()
 
template<typename RandomGenerator >
std::vector< SampleOutputsample (RandomGenerator &g, uint32_t num=1)
 
std::vector< SampleOutputsample (uint32_t num=1)
 
Episodeget (GameUID const &, EpisodeKey const &=kDefaultEpisodeKey)
 
bool has (GameUID const &, EpisodeKey const &=kDefaultEpisodeKey)
 
bool isDone (GameUID const &, EpisodeKey const &=kDefaultEpisodeKey)
 

Protected Member Functions

template<typename RandomGenerator >
SampleOutput sample_ (RandomGenerator &g)
 

Protected Attributes

Store storage_
 
UIDKeyStore dones_
 
std::shared_timed_mutex replayerRWMutex_
 

Detailed Description

Stores an unordered_map[GameUID] = unordered_map[int, Episode] All the public functions here should be autolocking and therefore relatively thread safe.

However, things like size do no perfectly accurately represent the size in a multithreaded environment.

Member Typedef Documentation

using cpid::ReplayBuffer::Episode = std::vector<std::shared_ptr<ReplayBufferFrame>>
using cpid::ReplayBuffer::SampleOutput = std::pair<EpisodeTuple, std::reference_wrapper<Episode>>
using cpid::ReplayBuffer::Store = std::unordered_map<GameUID, std::unordered_map<EpisodeKey, Episode>>
using cpid::ReplayBuffer::UIDKeyStore = std::unordered_map<GameUID, std::unordered_set<EpisodeKey>>

Member Function Documentation

Episode & cpid::ReplayBuffer::append ( GameUID  uid,
EpisodeKey  key,
std::shared_ptr< ReplayBufferFrame value,
bool  isDone = false 
)
void cpid::ReplayBuffer::clear ( )
void cpid::ReplayBuffer::erase ( GameUID const &  id,
EpisodeKey const &  key = kDefaultEpisodeKey 
)
Episode & cpid::ReplayBuffer::get ( GameUID const &  uid,
EpisodeKey const &  key = kDefaultEpisodeKey 
)
std::vector< std::pair< EpisodeTuple, std::reference_wrapper< Episode > > > cpid::ReplayBuffer::getAllEpisodes ( )
bool cpid::ReplayBuffer::has ( GameUID const &  uid,
EpisodeKey const &  key = kDefaultEpisodeKey 
)
bool cpid::ReplayBuffer::isDone ( GameUID const &  uid,
EpisodeKey const &  key = kDefaultEpisodeKey 
)
template<typename RandomGenerator >
std::vector< ReplayBuffer::SampleOutput > cpid::ReplayBuffer::sample ( RandomGenerator &  g,
uint32_t  num = 1 
)
inline
std::vector< std::pair< EpisodeTuple, std::reference_wrapper< Episode > > > cpid::ReplayBuffer::sample ( uint32_t  num = 1)
template<typename RandomGenerator >
ReplayBuffer::SampleOutput cpid::ReplayBuffer::sample_ ( RandomGenerator &  g)
inlineprotected
std::size_t cpid::ReplayBuffer::size ( ) const
std::size_t cpid::ReplayBuffer::size ( GameUID const &  id) const
std::size_t cpid::ReplayBuffer::sizeDone ( ) const
std::size_t cpid::ReplayBuffer::sizeDone ( GameUID const &  id) const

Member Data Documentation

UIDKeyStore cpid::ReplayBuffer::dones_
protected
std::shared_timed_mutex cpid::ReplayBuffer::replayerRWMutex_
mutableprotected
Store cpid::ReplayBuffer::storage_
protected

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