Empirical
|
#include <AvidaHardware.h>
Classes | |
struct | RegBackup |
Information about a register that is backed up, to be restored when current scope is exited. More... | |
struct | ScopeInfo |
As different scopes are stepped through, this class provides information about each one. More... | |
Public Types | |
enum | ScopeType { ScopeType::NONE =0, ScopeType::ROOT, ScopeType::BASIC, ScopeType::LOOP, ScopeType::FUNCTION } |
using | this_t = AvidaHardware< CPU_SIZE > |
using | stack_t = emp::vector< double > |
Public Member Functions | |
AvidaHardware () | |
Create a new AvidaGP seeding it with a genome. More... | |
AvidaHardware (const AvidaHardware< CPU_SIZE > &)=default | |
Copy constructor. More... | |
AvidaHardware (AvidaHardware< CPU_SIZE > &&)=default | |
Move constructor. More... | |
virtual | ~AvidaHardware () |
Destructor. More... | |
void | ExitScope () |
Run every time we need to exit the current scope. More... | |
virtual void | Reset () |
void | ResetIP () |
Reset the instruction pointer to the beginning of the genome AND reset scope. More... | |
double | GetReg (size_t id) const |
double | GetInput (int id) const |
const std::unordered_map< int, double > & | GetInputs () const |
size_t | GetNumInputs () const |
double | GetOutput (int id) const |
const std::unordered_map< int, double > & | GetOutputs () const |
size_t | GetNumOutputs () const |
const stack_t & | GetStack (size_t id) const |
int | GetFunStart (size_t id) const |
size_t | GetIP () const |
emp::vector< ScopeInfo > | GetScopeStack () const |
size_t | CurScope () const |
ScopeType | CurScopeType () const |
emp::vector< RegBackup > | GetRegStack () const |
emp::vector< size_t > | GetCallStack () const |
size_t | GetNumErrors () const |
double | GetTrait (size_t id) const |
const emp::vector< double > & | GetTraits () |
size_t | GetNumTraits () const |
void | SetReg (size_t id, double val) |
void | SetInput (int input_id, double value) |
void | SetInputs (const std::unordered_map< int, double > &vals) |
void | SetInputs (std::unordered_map< int, double > &&vals) |
void | SetOutput (int output_id, double value) |
void | SetOutputs (const std::unordered_map< int, double > &vals) |
void | SetOutputs (std::unordered_map< int, double > &&vals) |
double | PopStack (size_t id) |
void | PushStack (size_t id, double value) |
void | SetFunStart (size_t id, int value) |
void | SetIP (size_t pos) |
void | PushRegInfo (size_t scope_id, size_t reg_id) |
void | PushCallInfo (size_t pos) |
void | IncErrors () |
void | SetTrait (size_t id, double val) |
void | PushTrait (double val) |
void | PrintState (std::ostream &os=std::cout) const |
Print out the state of the virtual CPU. More... | |
void | IncReg (size_t reg_id) |
void | DecReg (size_t reg_id) |
void | NotReg (size_t reg_id) |
void | AddRegs (size_t reg0_id, size_t reg1_id, size_t reg2_id) |
void | SubRegs (size_t reg0_id, size_t reg1_id, size_t reg2_id) |
void | MultRegs (size_t reg0_id, size_t reg1_id, size_t reg2_id) |
void | DivRegs (size_t reg0_id, size_t reg1_id, size_t reg2_id) |
void | ModRegs (size_t reg0_id, size_t reg1_id, size_t reg2_id) |
void | RegTestEqu (size_t reg0_id, size_t reg1_id, size_t reg2_id) |
void | RegTestNEqu (size_t reg0_id, size_t reg1_id, size_t reg2_id) |
void | RegTestLess (size_t reg0_id, size_t reg1_id, size_t reg2_id) |
Public Attributes | |
emp::array< double, CPU_SIZE > | regs |
Registers used in the hardware. More... | |
std::unordered_map< int, double > | inputs |
Map of all available inputs (position -> value) More... | |
std::unordered_map< int, double > | outputs |
Map of all outputs (position -> value) More... | |
emp::array< stack_t, CPU_SIZE > | stacks |
Stacks for long-term storage. More... | |
emp::array< int, CPU_SIZE > | fun_starts |
Postions where functions being in genome. More... | |
size_t | inst_ptr |
Which code position should be executed next? More... | |
emp::vector< ScopeInfo > | scope_stack |
What scopes are we nested in? More... | |
emp::vector< RegBackup > | reg_stack |
What registers have been backed up? More... | |
emp::vector< size_t > | call_stack |
What function calls have to be returned from? More... | |
size_t | error_count |
How many errors have occurred? More... | |
emp::vector< double > | traits |
A simple way of recording which traits a CPU has demonstrated, and at what qaulity. More... | |
Core hardware for building an avida CPU.
CPU_SIZE | determines the number of registers, stacks, etc. to use. |
using emp::AvidaHardware< CPU_SIZE >::stack_t = emp::vector<double> |
using emp::AvidaHardware< CPU_SIZE >::this_t = AvidaHardware<CPU_SIZE> |
|
strong |
|
inline |
Create a new AvidaGP seeding it with a genome.
|
default |
Copy constructor.
|
default |
Move constructor.
|
inlinevirtual |
Destructor.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Run every time we need to exit the current scope.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
void emp::AvidaHardware< CPU_SIZE >::PrintState | ( | std::ostream & | os = std::cout | ) | const |
Print out the state of the virtual CPU.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inlinevirtual |
|
inline |
Reset the instruction pointer to the beginning of the genome AND reset scope.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
emp::vector<size_t> emp::AvidaHardware< CPU_SIZE >::call_stack |
What function calls have to be returned from?
size_t emp::AvidaHardware< CPU_SIZE >::error_count |
How many errors have occurred?
emp::array< int, CPU_SIZE > emp::AvidaHardware< CPU_SIZE >::fun_starts |
Postions where functions being in genome.
std::unordered_map<int, double> emp::AvidaHardware< CPU_SIZE >::inputs |
Map of all available inputs (position -> value)
size_t emp::AvidaHardware< CPU_SIZE >::inst_ptr |
Which code position should be executed next?
std::unordered_map<int, double> emp::AvidaHardware< CPU_SIZE >::outputs |
Map of all outputs (position -> value)
emp::vector<RegBackup> emp::AvidaHardware< CPU_SIZE >::reg_stack |
What registers have been backed up?
emp::array<double, CPU_SIZE> emp::AvidaHardware< CPU_SIZE >::regs |
Registers used in the hardware.
emp::vector<ScopeInfo> emp::AvidaHardware< CPU_SIZE >::scope_stack |
What scopes are we nested in?
emp::array< stack_t, CPU_SIZE > emp::AvidaHardware< CPU_SIZE >::stacks |
Stacks for long-term storage.
emp::vector<double> emp::AvidaHardware< CPU_SIZE >::traits |
A simple way of recording which traits a CPU has demonstrated, and at what qaulity.