- Main Page
- Classes
- Files

# NeuralNetwork.h

    00001 /*
    00002 * Neural Networks Tearm Project
    00003 * Martin Johne
    00004 * 04.10.2006
    00005 */
    00006 #pragma once
    00007 #include "LookUpTable.h"
    00008 #include "Symmetry.h"
    00009 #include "Muele.h"
    00010 #include "TestWin.h"
    00011
    00012 #define FILE_MARK 1649024562    // max long val 4,294,967,295
    00013
    00015 class CNeuralNetwork
    00016 {
    00017 public:
    00018
    00019         // methods
    00020
    00021         CNeuralNetwork(int boardSizeX, int boardSizeY, int boardSizeZ, int winFieldCount, int countHiddenNeurons, bool largeInputVector, CMuele *pMuele);
    00022         ~CNeuralNetwork(void);
    00023
    00025         double propagate(char *pBoard, char player, bool createTheInputVector = true);
    00027         void trainValue(char *pBoard, char player, double trainValue, double learnRate, double maxError);
    00029         int getBestMove(char *pBoard, char player);
    00031         void learn();
    00033         void learnTest();
    00035         void learnTest2();
    00037         void setLearnParameters();
    00039         bool saveNet(const wchar_t *pFileName);
    00041     bool loadNet(const wchar_t *pFileName);
    00042
    00043         // variables
    00044
    00045         int gamesCount, actualCycle;
    00046         unsigned trainingTime;
    00047
    00048         int numberInputNeurons;
    00049         int numberHiddenNeurons;
    00050
    00051         bool largeInputVector, wasTrained;
    00052
    00053         unsigned drawCount, win1Count, win2Count;
    00054         double maxErrorStart, maxErrorEnd;
    00055         double trainRateStart, trainRateEnd;
    00056         double stepSizeStart, stepSizeEnd;
    00057
    00058 private:
    00059
    00060         // methods
    00061
    00062         void createInputVector(const char *pBoard);
    00063         void aICompetition( char weakPlayer, int testCount, int &wonPlayer1, int &draws, int &wonPlayer2);
    00064         void resetWeights(char player);
    00065         void deleteUsedMemory();
    00066         void allocateMemory();
    00067         void xorTest();
    00068
    00069         // variables
    00070
    00071         int boardFieldCount;
    00072         double *pWeightsHidden1, *pWeightsHidden2;
    00073         double *pWeightsOut1, *pWeightsOut2;
    00074
    00075         double *pInputVector;
    00076         double *pGradientsHidden;
    00077         double *pOutputHidden;
    00078
    00079         int boardSizeX, boardSizeY, boardSizeZ;
    00080         int     boardFieldCountPlain;
    00081         int winFieldCount;
    00082
    00083         int strengthCount, maxDepth, netRaiting;
    00084         int maxDepthCount;
    00085
    00086         CSymmetry *pSymmetry;
    00087         CMuele    *pMuele;
    00088
    00089         char      *pBoard;
    00090         CTestWin  *pTestWinPlayer1, *pTestWinPlayer2;
    00091
    00092 };