forked from anyaevostinar/SymbulationEmp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGenomeLibrary.h
More file actions
86 lines (77 loc) · 1.89 KB
/
Copy pathGenomeLibrary.h
File metadata and controls
86 lines (77 loc) · 1.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#ifndef GENOME_LIBRARY
#define GENOME_LIBRARY
#include "Instructions.h"
#include "sgpl/program/Instruction.hpp"
#include "sgpl/program/Program.hpp"
#include "sgpl/library/OpLibrary.hpp"
#include "sgpl/operations/operations.hpp"
#include <cstddef>
#include <limits>
#include <unordered_set>
#include <set>
namespace sgpmode {
// NOTE - Discuss what instructions that we'd like to include
using Library = sgpl::OpLibrary<
sgpl::Nop<>,
inst::Increment,
inst::Decrement,
// sgpl::BitwiseShift, // NOTE - replaced ShiftLeft/ShiftRight with BitwiseShift instruction
// sgpl::Add,
// sgpl::Subtract,
inst::ShiftLeft,
inst::ShiftRight,
inst::Add,
inst::Subtract,
inst::Nand,
inst::Push,
inst::Pop,
inst::SwapStack,
inst::Swap,
inst::Reproduce,
inst::IO,
inst::JumpIfNEq,
inst::JumpIfLess,
inst::JumpIfEq,
inst::Donate,
inst::Steal,
inst::Infect,
inst::SenseTask,
sgpl::global::Anchor
>;
namespace lib_info {
const emp::map<std::string, size_t> arities {
{"Nop-0", 0}, {"ShiftLeft", 1}, {"ShiftRight", 1}, {"Increment", 1},
{"Decrement", 1}, {"Push", 1}, {"Pop", 1}, {"SwapStack", 0},
{"Swap", 2}, {"Add", 3}, {"Subtract", 3}, {"Nand", 3},
{"Reproduce", 0}, {"PrivateIO", 1}, {"SharedIO", 1}, {"Donate", 0},
{"Reuptake", 1}, {"Steal", 0}, {"Infect", 0}, {"DynamicInst", 3},
{"SenseTask", 2},
{"IO", 1}
};
}
// Unused instructions:
// inst::PrivateIO,
// inst::Donate,
// inst::Reuptake,
// inst::Infect,
// inst::DynamicInst
// inst::Steal
template<typename Iter>
void del_inst(
Iter begin,
Iter end,
const unsigned char inst,
const unsigned char num_inst
) {
unsigned char current = 0;
for (; begin != end; ++begin) {
if (*begin == inst) {
if (current == inst)
current = (current + 1) % num_inst;
*begin = current;
current = (current + 1) % num_inst;
}
}
}
}
#endif