-
Notifications
You must be signed in to change notification settings - Fork 36
/
NeuralNet.h
65 lines (52 loc) · 1.44 KB
/
NeuralNet.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
53
54
55
56
57
58
59
60
61
62
63
64
65
#ifndef _NEURAL_NET_H
#define _NEURAL_NET_H
//****************************************************************************
//**
//** NeuralNet.h
//**
//** Copyright (c) 2010 Matthew Robbins
//**
//** Author: Matthew Robbins
//** Created: 04/2010
//**
//****************************************************************************
#include <vector>
// Forward Declarations
namespace CarDemo
{
class NLayer;
class Genome;
};
namespace CarDemo
{
// For the record, I owe a great debt to the website ai-junkie for its walkthrough of a NN.
// Also, Brian Schwabs "AI Game Engine Programming" was another godsend that helped immensly with this
// implementation.
class NeuralNet
{
private:
int inputAmount;
int outputAmount;
std::vector<float> inputs;
NLayer* inputLayer;
std::vector<NLayer*> hiddenLayers;
NLayer* outputLayer;
std::vector<float> outputs;
protected:
public:
NeuralNet();
~NeuralNet();
void Update();
void SetInput(std::vector<float> in);
float GetOutput(unsigned int ID);
int GetTotalOutputs() const;
void ExportNet(char* filename);
void LoadNet(char* filename);
void CreateNet(int numOfHiddenLayers, int numOfInputs, int neuronsPerHidden, int numOfOutputs);
int GetNumOfHiddenLayers();
void ReleaseNet();
Genome* ToGenome();
void FromGenome(const Genome& genome, int numOfInputs, int neuronsPerHidden, int numOfOutputs);
};
}; // End namespace CarDemo.
#endif // #ifndef _NEURAL_NET_H