forked from karpathy/scriptsbots
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMLPBrain.h
45 lines (34 loc) · 852 Bytes
/
MLPBrain.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
#ifndef MLPBRAIN_H
#define MLPBRAIN_H
#include "settings.h"
#include "helpers.h"
#include <vector>
class MLPBox {
public:
MLPBox();
std::vector<float> w; //weight of each connecting box
std::vector<int> id; //id in boxes[] of the connecting box
float kp; //damper
float gw; //global w
float bias;
//state variables
float target; //target value this node is going toward
float out; //current output
};
/**
* Damped Weighted Recurrent AND/OR Network
*/
class MLPBrain
{
public:
std::vector<MLPBox> boxes;
MLPBrain();
MLPBrain(const MLPBrain &other);
virtual MLPBrain& operator=(const MLPBrain& other);
void tick(std::vector<float>& in, std::vector<float>& out);
void mutate(float MR, float MR2);
MLPBrain crossover( const MLPBrain &other );
private:
void init();
};
#endif