forked from anyaevostinar/SGPLite-Lab-Starter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Org.h
52 lines (41 loc) · 1020 Bytes
/
Org.h
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
#ifndef ORG_H
#define ORG_H
#include "CPU.h"
#include "OrgState.h"
#include "emp/Evolve/World_structure.hpp"
class Organism {
CPU cpu;
public:
Organism(OrgWorld *world, double points = 0.0) : cpu(world) {
SetPoints(points);
}
void SetPoints(double _in) { cpu.state.points = _in; }
void AddPoints(double _in) { cpu.state.points += _in; }
double GetPoints() {return cpu.state.points;}
void Reset() {
cpu.Reset();
}
void Mutate() {
cpu.Mutate();
}
std::optional<Organism> CheckReproduction() {
if (GetPoints() > 20) {
Organism offspring = *this;
offspring.Reset();
offspring.Mutate();
AddPoints(-20);
return offspring;
}
return {};
}
void Process(emp::WorldPosition current_location) {
cpu.state.current_location = current_location;
//TODO: Run the CPU!
}
void PrintGenome() {
std::cout << "program ------------" << std::endl;
cpu.PrintGenome();
std::cout << "end ---------------" << std::endl;
}
};
#endif