IAtari
Genetic algorithm generating AI capable to play Atari2600 games.
Utils Namespace Reference

A set of useful method and class. More...

Classes

class  Random
 RNG based on Xoroshiro128+. More...
 
class  ThreadGroup
 An implementation of Thread group. More...
 
class  ThreadPool
 An implementation of Thread pool. More...
 

Functions

static std::uint64_t splitmix64 (std::uint64_t z)
 
void atomic_add (std::atomic< T > &f, T d)
 Perform an atomic addition. More...
 
rotl (const T x, const int k)
 Rotate bytes to the left. More...
 
bool is7bit (int c)
 Check if a value is written on 7 bits. More...
 
size_t ceilMultiple (size_t a, size_t b)
 Calculate the closest value from a such that this new value is a multiple of b. More...
 
int secam_to_range_index (int i)
 Transform a secam color value to a power of two. More...
 
void secam210x160_to_42x32 (const std::vector< unsigned char > &screen, std::vector< unsigned char > &screen42x32)
 Reduce the screen from 210x160 to 42x32. More...
 
void init_ALE ()
 Initialize the emulator from the config file. More...
 
vector< vector< string > > read_Config ()
 Store values extracted from the config file to a vector. More...
 

Detailed Description

A set of useful method and class.

Author
Gian-Carlo Pascutto

Function Documentation

◆ atomic_add()

Utils::atomic_add ( std::atomic< T > &  f,
d 
)

Perform an atomic addition.

Parameters
[in,out]fOriginal atomic value
dValue added to the atomic value

◆ ceilMultiple()

size_t Utils::ceilMultiple ( size_t  a,
size_t  b 
)

Calculate the closest value from a such that this new value is a multiple of b.

Parameters
aThe divided
bThe divisor
Returns
The closest value from a such that b divide this value

◆ init_ALE()

Utils::init_ALE ( )

Initialize the emulator from the config file.

The properties set are repeat_action_probability, display_screen, sound, ROM and colourPalette

◆ is7bit()

bool Utils::is7bit ( int  c)
inline

Check if a value is written on 7 bits.

Parameters
cThe checked value
Returns
True if the value is written on 7 bits, false otherwise

◆ read_Config()

Utils::read_Config ( )

Store values extracted from the config file to a vector.

The config file is config.config. This file have to be flawlessly written or the algorithm will crash.

Returns
A vector of vector of string. All the lines of the file are stored in a vector. Lines are represented with a vector containing a parameter and his value

◆ rotl()

Utils::rotl ( const T  x,
const int  k 
)

Rotate bytes to the left.

Parameters
xValue to be rotated
kNumber of bits to shift
Returns
The rotated value

◆ secam210x160_to_42x32()

Utils::secam210x160_to_42x32 ( const std::vector< unsigned char > &  screen,
std::vector< unsigned char > &  screen42x32 
)

Reduce the screen from 210x160 to 42x32.

Parameters
[in]screenThe input screen (pointer vector)
[out]screen42x32The output screen (pointer vector)
See also
secam_to_range_index()

◆ secam_to_range_index()

int Utils::secam_to_range_index ( int  i)
inline

Transform a secam color value to a power of two.

Parameters
iThe color value we want to transform
Returns
The transformed color value

◆ splitmix64()

static std::uint64_t Utils::splitmix64 ( std::uint64_t  z)
static