![]() |
IAtari
Genetic algorithm generating AI capable to play Atari2600 games.
|
Represents an agent, i.e. an AI. More...
#include <agent.hpp>
Classes | |
struct | parameters |
Represents the caracteristics of an agent. More... | |
Public Types | |
enum | opcode { OP_NOP, OP_ADD, OP_MINUS, OP_MAX, OP_MIN, OP_UMINUS, OP_MUL, OP_DIV, OP_LOG, OP_EXP, OP_COS, OP_SIN, OP_POPCOUNT, OP_IF, OP_IF_GOTO, OP_SIZE } |
Enumeration of all the operation available for an agent. More... | |
using | instruction = uint64_t |
using | reg = double |
Public Member Functions | |
agent ()=default | |
Standard constructor (Empty agent) More... | |
agent (const parameters ¶ms) | |
Construct an agent with parameters. More... | |
int | get_action (const std::vector< unsigned char > &screen) |
Execute the program on a particular frame and choose an action. More... | |
void | serialize (Archive &ar, const unsigned int) |
Save/Load agent with archive. More... | |
void | reset_registers () |
Fills the registers "temporary" and "outputs" files with 0. More... | |
void | reset () |
Fills all the registers files with 0 and set nb_steps and current_part to 0. More... | |
void | execute_instruction (const std::vector< unsigned char > &screen, int &pc) |
Perform the operation corresponding to this instruction. More... | |
auto | begin_outputs () |
Access the beginning of the register file "outputs". More... | |
auto | end_outputs () |
Access the end of the register file "outputs". More... | |
std::string | reg_to_string (int reg) const |
Represent a register as a string. More... | |
void | print_instruction (std::ostream &, instruction ins) const |
Display an instruction as a String through a outputStream. More... | |
Public Attributes | |
parameters | params |
std::vector< instruction > | program |
std::vector< reg > | registers |
int | nb_steps = 0 |
int | current_part = 0 |
Represents an agent, i.e. an AI.
using agent::instruction = uint64_t |
using agent::reg = double |
enum agent::opcode |
|
default |
Standard constructor (Empty agent)
agent::agent | ( | const parameters & | params | ) |
Construct an agent with parameters.
Initializes params, but also the program size and the register files size.
params | Parameters of this agent |
|
inline |
Access the beginning of the register file "outputs".
|
inline |
Access the end of the register file "outputs".
|
inline |
Perform the operation corresponding to this instruction.
screen | The register file corresponding to the reduced screen |
pc | The program counter, corresponds to an instruction |
agent::get_action | ( | const std::vector< unsigned char > & | screen | ) |
Execute the program on a particular frame and choose an action.
screen | Register file corresponding to the reduced screen |
agent::print_instruction | ( | std::ostream & | os, |
instruction | ins | ||
) | const |
Display an instruction as a String through a outputStream.
os | The output stream used to display |
ins | The instruction to be displayed |
agent::reg_to_string | ( | int | reg | ) | const |
Represent a register as a string.
reg | The index of a register |
agent::reset | ( | ) |
Fills all the registers files with 0 and set nb_steps and current_part to 0.
agent::reset_registers | ( | ) |
Fills the registers "temporary" and "outputs" files with 0.
|
inline |
Save/Load agent with archive.
[in,out] | ar | Archived agent |
int agent::current_part = 0 |
Number corresponding to the currently executed part
int agent::nb_steps = 0 |
Total number of execution of the current part
parameters agent::params |
Caracteristics of this agent
std::vector<instruction> agent::program |
List of instructions representing the program
std::vector<reg> agent::registers |
Register files of this agent