Skip to content

Commit

Permalink
Switch VCPU inst methods from using index to ID
Browse files Browse the repository at this point in the history
  • Loading branch information
FergusonAJ committed Jul 4, 2022
1 parent 6cdc08d commit 78306cf
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions include/emp/hardware/VirtualCPU.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,17 +230,19 @@ namespace emp{
}
/// Return the first instruction in the instruction library
inst_t GetDefaultInst() const{
return inst_t(0, GetInstLib()->GetID(0));
return inst_t(GetInstLib()->GetIndex(0), 0);
}
/// Add one or more default instructions to the end of the genome
void PushDefaultInst(size_t count=1) {
PushInst( inst_t(0, GetInstLib()->GetID(0)), count );
PushInst( inst_t(GetInstLib()->GetIndex(0), 0), count );
nops_need_curated = true;
}
/// Return a random instruction from the instruction library
inst_t GetRandomInst(Random & rand) {
size_t idx = rand.GetUInt(GetInstLib()->GetSize());
size_t id = GetInstLib()->GetID(idx);
size_t id = rand.GetUInt(GetInstLib()->GetSize());
size_t idx = GetInstLib()->GetIndex(id);
//size_t idx = rand.GetUInt(GetInstLib()->GetSize());
//size_t id = GetInstLib()->GetID(idx);
return inst_t(idx, id);
}
/// Overwrite the instruction at the given genome index with passed instruction
Expand Down

0 comments on commit 78306cf

Please sign in to comment.