1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-28 23:06:24 +02:00
vcmi/AI/GeniusAI/neuralNetwork.h
Trevor Standley a3b6bb4892 AI loads .brain file which contains a list of objects to visit and what features are necessary to determine how valuable that objective is.
AI creates random neural networks and assumes that their outputs are trained values.
2009-08-18 07:37:45 +00:00

67 lines
1.7 KiB
C++

/*******************************************************************
* addapted by Trevor Standley for use as a function approximator
* Addapted from:
* Basic Feed Forward Neural Network Class
* ------------------------------------------------------------------
* Bobby Anguelov - takinginitiative.wordpress.com (2008)
* MSN & email: banguelov@cs.up.ac.za
********************************************************************/
#ifndef NEURAL_NETWORK_H
#define NEURAL_NETWORK_H
//standard includes
#include <iostream>
#include <vector>
#include <fstream>
#include <cmath>
#include <limits>
class neuralNetwork
{
private:
//number of neurons
int nInput, nHidden1, nHidden2, nOutput;
//neurons
double* inputNeurons;
double* hiddenNeurons1;
double* hiddenNeurons2;
double* outputNeurons;
//weights
double** wInputHidden;
double** wHidden2Hidden;
double** wHiddenOutput;
public:
//constructor & destructor
neuralNetwork(int numInput, int numHidden1, int numHidden2, int numOutput);
neuralNetwork(const neuralNetwork&);
neuralNetwork();
void operator = (const neuralNetwork&);
~neuralNetwork();
//weight operations
double* feedForwardPattern( double* pattern );
void backpropigate(double* pattern, double OLR, double H2LR, double H1LR );
void tweakWeights(double howMuch);
void mate(const neuralNetwork&n1,const neuralNetwork&n2);
private:
void initializeWeights();
inline double activationFunction( double x );
void feedForward( double* pattern );
};
std::istream & operator >> (std::istream &, neuralNetwork & ann);
std::ostream & operator << (std::ostream &, const neuralNetwork & ann);
#endif