Empirical
|
#include <AvidaCPU_InstLib.h>
Public Types | |
using | hardware_t = HARDWARE_T |
using | arg_t = ARG_T |
using | this_t = AvidaCPU_InstLib< HARDWARE_T, ARG_T, ARG_COUNT > |
using | inst_t = typename hardware_t::inst_t |
using | genome_t = emp::vector< inst_t > |
using | fun_t = std::function< void(hardware_t &, const inst_t &)> |
using | inst_properties_t = std::unordered_set< std::string > |
Public Member Functions | |
const std::string & | GetName (size_t id) const |
Return the name associated with the specified instruction ID. More... | |
const fun_t & | GetFunction (size_t id) const |
Return the function associated with the specified instruction ID. More... | |
size_t | GetNumArgs (size_t id) const |
Return the number of arguments expected for the specified instruction ID. More... | |
const std::string & | GetDesc (size_t id) const |
Return the provided description for the provided instruction ID. More... | |
ScopeType | GetScopeType (size_t id) const |
What type of scope does this instruction state? ScopeType::NONE is default. More... | |
size_t | GetScopeArg (size_t id) const |
If this instruction alters scope, identify which argument does so. More... | |
const inst_properties_t & | GetProperties (size_t id) const |
Return the set of properties for the provided instruction ID. More... | |
bool | HasProperty (size_t id, std::string property) const |
Does the given instruction ID have the given property value? More... | |
size_t | GetSize () const |
Get the number of instructions in this set. More... | |
bool | IsInst (const std::string name) const |
size_t | GetID (const std::string &name) const |
Return the ID of the instruction that has the specified name. More... | |
arg_t | GetArg (const std::string &name) |
Return the argument value associated with the provided keyword. More... | |
void | AddInst (const std::string &name, const fun_t &fun_call, size_t num_args=0, const std::string &desc="", ScopeType scope_type=ScopeType::NONE, size_t scope_arg=(size_t)-1, const inst_properties_t &inst_properties=inst_properties_t()) |
Add a new instruction to the set. More... | |
void | AddArg (const std::string &name, arg_t value) |
Specify a keyword and arg value. More... | |
void | ProcessInst (hardware_t &hw, const inst_t &inst) const |
Process a specified instruction in the provided hardware. More... | |
template<typename IN_HW > | |
void | ProcessInst (emp::Ptr< IN_HW > hw, const inst_t &inst) const |
Process a specified instruction on hardware that can be converted to the correct type. More... | |
void | WriteGenome (const genome_t &genome, std::ostream &os=std::cout) const |
Write out a full genome to the provided ostream. More... | |
void | ReadInst (genome_t &genome, std::string info) const |
Read the instruction in the provided info and append it to the provided genome. More... | |
Static Public Member Functions | |
static void | Inst_Inc (hardware_t &hw, const inst_t &inst) |
static void | Inst_Dec (hardware_t &hw, const inst_t &inst) |
static void | Inst_Not (hardware_t &hw, const inst_t &inst) |
static void | Inst_SetReg (hardware_t &hw, const inst_t &inst) |
static void | Inst_Add (hardware_t &hw, const inst_t &inst) |
static void | Inst_Sub (hardware_t &hw, const inst_t &inst) |
static void | Inst_Mult (hardware_t &hw, const inst_t &inst) |
static void | Inst_Div (hardware_t &hw, const inst_t &inst) |
static void | Inst_Mod (hardware_t &hw, const inst_t &inst) |
static void | Inst_TestEqu (hardware_t &hw, const inst_t &inst) |
static void | Inst_TestNEqu (hardware_t &hw, const inst_t &inst) |
static void | Inst_TestLess (hardware_t &hw, const inst_t &inst) |
static void | Inst_If (hardware_t &hw, const inst_t &inst) |
static void | Inst_While (hardware_t &hw, const inst_t &inst) |
static void | Inst_Countdown (hardware_t &hw, const inst_t &inst) |
static void | Inst_Break (hardware_t &hw, const inst_t &inst) |
static void | Inst_Scope (hardware_t &hw, const inst_t &inst) |
static void | Inst_Define (hardware_t &hw, const inst_t &inst) |
static void | Inst_Call (hardware_t &hw, const inst_t &inst) |
static void | Inst_Push (hardware_t &hw, const inst_t &inst) |
static void | Inst_Pop (hardware_t &hw, const inst_t &inst) |
static void | Inst_Input (hardware_t &hw, const inst_t &inst) |
static void | Inst_Output (hardware_t &hw, const inst_t &inst) |
static void | Inst_CopyVal (hardware_t &hw, const inst_t &inst) |
static void | Inst_ScopeReg (hardware_t &hw, const inst_t &inst) |
static const this_t & | DefaultInstLib () |
static constexpr char | GetSymbol (size_t id) |
Retrieve a unique letter associared with the specified instruction ID. More... | |
static constexpr size_t | GetID (char symbol) |
Return the ID of the instruction associated with the specified symbol. More... | |
Static Public Attributes | |
static constexpr size_t | arg_count = ARG_COUNT |
Protected Attributes | |
emp::vector< InstDef > | inst_lib |
Full definitions for instructions. More... | |
emp::vector< fun_t > | inst_funs |
Map of instruction IDs to their functions. More... | |
std::map< std::string, size_t > | name_map |
How do names link to instructions? More... | |
std::map< std::string, arg_t > | arg_map |
How are different arguments named? More... | |
AvidaCPU_InstLib is a pure-virtual class that defines a series of instructions that can be used with AvidaCPU_Base or any of its derived classes.
using emp::AvidaCPU_InstLib< HARDWARE_T, ARG_T, ARG_COUNT >::arg_t = ARG_T |
|
inherited |
|
inherited |
using emp::AvidaCPU_InstLib< HARDWARE_T, ARG_T, ARG_COUNT >::hardware_t = HARDWARE_T |
|
inherited |
using emp::AvidaCPU_InstLib< HARDWARE_T, ARG_T, ARG_COUNT >::inst_t = typename hardware_t::inst_t |
using emp::AvidaCPU_InstLib< HARDWARE_T, ARG_T, ARG_COUNT >::this_t = AvidaCPU_InstLib<HARDWARE_T, ARG_T, ARG_COUNT> |
|
inlineinherited |
Specify a keyword and arg value.
|
inlineinherited |
Add a new instruction to the set.
name | A unique string name for this instruction. |
fun_call | The function that should be called when this instruction is executed. |
num_args | How many arguments does this function require? (default=0) |
desc | A description of how this function operates. (default="") |
scope_type | Type of scope does this instruction creates. (default=ScopeType::NONE) |
scope_arg | If instruction changes scope, which argument specified new scope? (defualt=-1) |
|
inlinestatic |
|
inlineinherited |
Return the argument value associated with the provided keyword.
|
inlineinherited |
Return the provided description for the provided instruction ID.
|
inlineinherited |
Return the function associated with the specified instruction ID.
|
inlineinherited |
Return the ID of the instruction that has the specified name.
|
inlinestaticinherited |
Return the ID of the instruction associated with the specified symbol.
|
inlineinherited |
Return the name associated with the specified instruction ID.
|
inlineinherited |
Return the number of arguments expected for the specified instruction ID.
|
inlineinherited |
Return the set of properties for the provided instruction ID.
|
inlineinherited |
If this instruction alters scope, identify which argument does so.
|
inlineinherited |
What type of scope does this instruction state? ScopeType::NONE is default.
|
inlineinherited |
Get the number of instructions in this set.
|
inlinestaticinherited |
Retrieve a unique letter associared with the specified instruction ID.
|
inlineinherited |
Does the given instruction ID have the given property value?
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlineinherited |
|
inlineinherited |
Process a specified instruction in the provided hardware.
|
inlineinherited |
Process a specified instruction on hardware that can be converted to the correct type.
|
inlineinherited |
Read the instruction in the provided info and append it to the provided genome.
|
inlineinherited |
Write out a full genome to the provided ostream.
|
static |
|
protectedinherited |
How are different arguments named?
|
protectedinherited |
Map of instruction IDs to their functions.
|
protectedinherited |
Full definitions for instructions.
|
protectedinherited |
How do names link to instructions?