forked from Ramblurr/scriptbots
-
Notifications
You must be signed in to change notification settings - Fork 44
/
DWRAONBrain.h
49 lines (36 loc) · 1.01 KB
/
DWRAONBrain.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
#ifndef DWRAONBRAIN_H
#define DWRAONBRAIN_H
#include "settings.h"
#include "helpers.h"
#include <vector>
class Box {
public:
Box();
//props
int type; //0: AND, 1:OR
float kp; //kp: damping strength
std::vector<float> w; //weight of each connecting box (in [0,inf]
std::vector<int> id; //id in boxes[] of the connecting box
std::vector<bool> notted; //is this input notted before coming in?
float bias;
//state variables
float target; //target value this node is going toward
float out; //current output, and history. 0 is farthest back. -1 is latest
};
/**
* Damped Weighted Recurrent AND/OR Network
*/
class DWRAONBrain
{
public:
std::vector<Box> boxes;
DWRAONBrain();
DWRAONBrain(const DWRAONBrain &other);
virtual DWRAONBrain& operator=(const DWRAONBrain& other);
void tick(std::vector<float>& in, std::vector<float>& out);
void mutate(float MR, float MR2);
DWRAONBrain crossover( const DWRAONBrain &other );
private:
void init();
};
#endif