bump up
[mancala] / src / MoveGenerator.h
1 /*
2 Mancala - A Historical Board Game
3 Copyright (C) 2009-2010 A.H.M.Mahfuzur Rahman 65mahfuz90@gmail.com
4 Copyright (c) 2010 Reto Zingg g.d0b3rm4n@gmail.com
5
6 This program is free software; you can redistribute it and/or
7 modify it under the terms of the GNU General Public License as
8 published by the Free Software Foundation; either version 2 of
9 the License, or (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program.  If not, see <http://www.gnu.org/licenses/>.
18 */
19
20
21 #ifndef MOVEGENERATOR_H
22 #define MOVEGENERATOR_H
23
24
25 #include <QList>
26 // #include <kdebug.h>
27
28 class GameController;
29 class GameInfo;
30 class Node;
31
32 class MoveGenerator{
33
34     public:
35
36         MoveGenerator(int gameDifficulty,GameInfo *gameInfo,GameController *gameController);
37
38         void changeDifficulty(int gameDifficulty){
39             // kDebug() << "GameDifficulty Changed to: " << gameDifficulty;
40             m_gameDifficulty = gameDifficulty;
41         }
42         //Will be called when we need a move and pass the current board state
43         int bestMove(QList<int> ,bool );
44         int maxValue(Node *currentNode,int alpha,int beta);
45         int minValue(Node *currentNode,int alpha,int beta);
46
47         void copyBoard(Node* to,Node* from);
48         void copyBoard(Node *to,QList<int>board);
49         void simulateMoves(Node *currentNode,QList<Node*>& );
50
51         bool isGameOver(QList<int> board);
52         void showBoardState(Node* node);
53
54     private:
55
56
57         QList<int> allCupIndexes;
58         QList<int> allEvaluations;
59         GameInfo* m_gameInfo;
60         GameController* m_gameController;
61         int m_searchDepth;
62         int m_gameDifficulty;
63         int m_depthList[3];
64
65 };
66
67 //Node of the Minimax Tree
68 class Node{
69
70     public:
71         Node(GameInfo *gameInfo);
72
73         int evaluationFunction(GameController* controller);
74         QList<int> getBoard(){ return m_boardState; }
75         void setBoard(QList<int>board);
76
77         void setDepth(int depth){ m_depth = depth;}
78         void setTurn(bool turn){ m_humanTurn = turn;}
79         void setMove(int move){ m_move = move;}
80
81         int depth() const{ return m_depth;}
82         int move() const{return m_move;}
83         bool turn() const{ return m_humanTurn;}
84
85
86     private:
87
88         GameInfo* m_gameInfo;
89         int m_depth;
90         bool m_humanTurn;
91         QList<int> m_boardState;
92         int m_move;     //from which cup the move has been generated
93 };
94
95 #endif // MOVEGENERATOR_H