@@ -32,8 +32,8 @@ namespace emp {
3232
3333 /* *
3434 * @brief A linear GP (inspired by AvidaGP) virtual hardware CPU that supports an event-driven programming paradigm.
35- * @note The terminology used throughout this class is out of date. EventDrivenGP will eventually change to 'SignalGP',
36- * and our terminology will be updated throughout.
35+ * @note The terminology used throughout this class is out of date. EventDrivenGP will eventually change to 'SignalGP',
36+ * and our terminology will be updated throughout.
3737 * @details
3838 * The EventDrivenGP virtual hardware runs programs where each program is a set of named functions.
3939 * Function names are mutable bit strings, or affinities, and each function consists of a sequence
@@ -95,13 +95,13 @@ namespace emp {
9595 * * Each event type has a registered event handler that gets called to handle a dispatched
9696 * event.
9797 */
98- template <size_t AFFINITY_WIDTH>
98+ template <size_t AFFINITY_WIDTH, typename TRAIT_TYPE= double >
9999 class EventDrivenGP_AW {
100100 public:
101101 // / Maximum number of instruction arguments. Currently hardcoded. At some point, will make flexible.
102102 static constexpr size_t MAX_INST_ARGS = 3 ;
103103
104- using EventDrivenGP_t = EventDrivenGP_AW<AFFINITY_WIDTH>; // < Resolved type for this templated class.
104+ using EventDrivenGP_t = EventDrivenGP_AW<AFFINITY_WIDTH, TRAIT_TYPE >; // < Resolved type for this templated class.
105105 using mem_key_t = int ; // < Hardware memory map key type.
106106 using mem_val_t = double ; // < Hardware memory map value type.
107107 using memory_t = std::unordered_map<mem_key_t , mem_val_t >; // < Hardware memory map type.
@@ -618,7 +618,7 @@ namespace emp {
618618 program_t program; // < Hardware's associated program (set of functions).
619619 memory_t shared_mem; // < Hardware's shared memory map. All cores have access to the same shared memory.
620620 std::deque<event_t > event_queue; // < Hardware's event queue. Where events go to be handled (in order of reception).
621- emp::vector<double > traits; // < Generic traits vector. Whatever uses the hardware must define/keep track of what traits mean.
621+ emp::vector<TRAIT_TYPE > traits; // < Generic traits vector. Whatever uses the hardware must define/keep track of what traits mean.
622622 size_t errors; // < Errors committed by hardware while executing. (e.g. divide by 0, etc.)
623623 size_t max_cores; // < Maximum number of parallel execution stacks that can be spawned. Increasing this value drastically slows things down.
624624 size_t max_call_depth; // < Maximum depth of calls per execution stack.
@@ -807,7 +807,7 @@ namespace emp {
807807 }
808808
809809 // / Get a particular trait given its ID.
810- double GetTrait (size_t id) const { emp_assert (id < traits.size ()); return traits[id]; }
810+ TRAIT_TYPE GetTrait (size_t id) const { emp_assert (id < traits.size ()); return traits[id]; }
811811
812812 // / Get current number of errors committed by this hardware.
813813 size_t GetNumErrors () const { return errors; }
@@ -830,7 +830,7 @@ namespace emp {
830830 bool IsStochasticFunCall () const { return stochastic_fun_call; }
831831
832832 // / Get all hardware cores.
833- // / NOTE: use responsibly!
833+ // / NOTE: use responsibly!
834834 emp::vector<exec_stk_t > & GetCores () { return cores; }
835835
836836 // / Get the currently executing core ID. If hardware is not in the middle of an execution cycle
@@ -949,7 +949,7 @@ namespace emp {
949949
950950 // / Set trait in traints vector given by id to value given by val.
951951 // / Will resize traits vector if given id is greater than current traits vector size.
952- void SetTrait (size_t id, double val) {
952+ void SetTrait (size_t id, TRAIT_TYPE val) {
953953 if (id >= traits.size ()) traits.resize (id+1 , 0.0 );
954954 traits[id] = val;
955955 }
@@ -969,7 +969,7 @@ namespace emp {
969969 }
970970
971971 // / Push a trait onto end of traits vector.
972- void PushTrait (double val) { traits.emplace_back (val); }
972+ void PushTrait (TRAIT_TYPE val) { traits.emplace_back (val); }
973973
974974 // / Shortcut to this hardware object's program's SetInst function of the same signature.
975975 void SetInst (size_t fID , size_t pos, const inst_t & inst) {
@@ -1610,17 +1610,17 @@ namespace emp {
16101610 // / Default instruction: Fork
16111611 // / Number of instruction arguments: 0
16121612 // / Description: Self-signal. Fork a new thread, using tag-based referencing to determine the appropriate
1613- // / function to call on the new thread.
1613+ // / function to call on the new thread.
16141614 static void Inst_Fork (EventDrivenGP_t & hw, const inst_t & inst) {
16151615 State & state = hw.GetCurState ();
16161616 hw.SpawnCore (inst.affinity , hw.GetMinBindThresh (), state.local_mem , false );
16171617 }
16181618
16191619 // / Default instruction: Terminate
16201620 // / Number of instruction arguments: 0
1621- // / Description: Terminate the thread that executes this instruction.
1622- // / WARNING: This instruction does not respect any 'main' function calls.
1623- // / *Any* thread where this is called is terminated.
1621+ // / Description: Terminate the thread that executes this instruction.
1622+ // / WARNING: This instruction does not respect any 'main' function calls.
1623+ // / *Any* thread where this is called is terminated.
16241624 static void Inst_Terminate (EventDrivenGP_t & hw, const inst_t & inst) {
16251625 // Pop all the call states from current core.
16261626 exec_stk_t & core = hw.GetCurCore ();
0 commit comments