IAtari
Genetic algorithm generating AI capable to play Atari2600 games.
slave< Res, Params > Class Template Reference

Slave part of the algorithm, perform test on agents. More...

#include <slave.hpp>

Public Member Functions

 slave (const std::string &master_name, int port, worker w, int duration=1e6)
 Standard constructor. More...
 
void run ()
 In a coroutine, initialize a connection with the master throught a socket and perform as many test as requested. More...
 
message::result< Res > do_work (const message::request< Params > &)
 Test an agent. More...
 

Private Types

using worker = std::function< message::result< Res >(const message::request< Params > &)>
 

Private Attributes

std::string master_name
 
std::string port
 
worker producer
 
int duration
 

Detailed Description

template<typename Res, typename Params>
class slave< Res, Params >

Slave part of the algorithm, perform test on agents.

Member Typedef Documentation

◆ worker

template<typename Res , typename Params >
using slave< Res, Params >::worker = std::function<message::result<Res>(const message::request<Params>&)>
private

Constructor & Destructor Documentation

◆ slave()

template<typename Res , typename Params >
slave< Res, Params >::slave ( const std::string &  master_name,
int  port,
worker  w,
int  duration = 1e6 
)
inline

Standard constructor.

Parameters
master_nameName of the machine that owned this slave
portPort used to communicate over the network
wMethod used to test the agents
durationSlave max life-time, 1,000,000 minutes by default

Member Function Documentation

◆ do_work()

template<typename Res , typename Params >
message::result< Res > slave< Res, Params >::do_work ( const message::request< Params > &  request)

Test an agent.

Parameters
requestAgent to be tested
Returns
Result (score) obtained by the agent

◆ run()

template<typename Res , typename Params >
void slave< Res, Params >::run ( )

In a coroutine, initialize a connection with the master throught a socket and perform as many test as requested.

First of all, a socket is created and attempt a connection to the master.
Then, when the slave receives a request, the given agent is tested and the result is sent back to the master.
The slave continues to work until the socket is disconnected or the slave duration is exceeded.

Member Data Documentation

◆ duration

template<typename Res , typename Params >
int slave< Res, Params >::duration
private

Slave max life-time in minutes

◆ master_name

template<typename Res , typename Params >
std::string slave< Res, Params >::master_name
private

Name of the machine that owned this slave

◆ port

template<typename Res , typename Params >
std::string slave< Res, Params >::port
private

Port used to communicate over the network

◆ producer

template<typename Res , typename Params >
worker slave< Res, Params >::producer
private

Method used to test the agents


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