3 #include <boost/serialization/vector.hpp> 58 template <
typename Archive>
134 int get_action(
const std::vector<unsigned char>& screen);
136 template <
typename Archive>
Definition: agent.hpp:101
int time_by_part
Definition: agent.hpp:29
int nb_long_term_registers
Definition: agent.hpp:26
parameters(int input_size, int output_size, int nb_registers, int nb_long_term_registers, int program_size, int nb_parts, int time_by_part)
Constructor entirely initializing parameters.
Definition: agent.hpp:50
int nb_steps
Definition: agent.hpp:108
void serialize(Archive &ar, const unsigned int)
Save/Load parameters with archive.
Definition: agent.hpp:67
void mutate(agent &a)
Mutate an agent, i.e. modify some instructions.
Definition: agent.cpp:327
void initialize(agent &a)
Initialize an agent with random instructions.
Definition: agent.cpp:319
void reset()
Fills all the registers files with 0 and set nb_steps and current_part to 0.
Definition: agent.cpp:19
Represents the caracteristics of an agent.
Definition: agent.hpp:22
auto begin_outputs()
Access the beginning of the register file "outputs".
Definition: agent.cpp:121
int input_size
Definition: agent.hpp:23
agent()=default
Standard constructor (Empty agent)
int nb_parts
Definition: agent.hpp:28
void execute_instruction(const std::vector< unsigned char > &screen, int &pc)
Perform the operation corresponding to this instruction.
Definition: agent.cpp:31
void reset_registers()
Fills the registers "temporary" and "outputs" files with 0.
Definition: agent.cpp:26
int program_size
Definition: agent.hpp:27
Represents an agent, i.e. an AI.
Definition: agent.hpp:16
Handle genetic operations performed on agents.
Definition: agent.cpp:271
parameters()=default
Standard constructor.
opcode
Enumeration of all the operation available for an agent.
Definition: agent.hpp:84
auto end_outputs()
Access the end of the register file "outputs".
Definition: agent.cpp:126
std::string reg_to_string(int reg) const
Represent a register as a string.
Definition: agent.cpp:166
void serialize(Archive &ar, const unsigned int)
Save/Load agent with archive.
Definition: agent.hpp:145
int output_size
Definition: agent.hpp:24
std::ostream & operator<<(std::ostream &, const agent &)
Operator << overloaded so that an agent's program can be displayed by using this operator directly on...
Definition: agent.cpp:260
int get_action(const std::vector< unsigned char > &screen)
Execute the program on a particular frame and choose an action.
Definition: agent.cpp:131
std::vector< reg > registers
Definition: agent.hpp:107
parameters params
Definition: agent.hpp:105
int nb_registers
Definition: agent.hpp:25
void crossover(agent &a1, agent &a2)
Swap instructions between two agents.
Definition: agent.cpp:345
void print_instruction(std::ostream &, instruction ins) const
Display an instruction as a String through a outputStream.
Definition: agent.cpp:177
Definition: agent.hpp:100
uint64_t instruction
Definition: agent.hpp:103
double reg
Definition: agent.hpp:104
std::vector< instruction > program
Definition: agent.hpp:106
int current_part
Definition: agent.hpp:109