Debian Codegraph @

src/checkers.h

raw symbols SCIP
1 /***************************************************************************
2 * Copyright (C) 2002-2003 Andi Peredri *
3 * [email protected] *
4 * Copyright (C) 2004-2005 Artur Wiebe *
5 * [email protected] *
6 * *
7 * This program is free software; you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation; either version 2 of the License, or *
10 * (at your option) any later version. *
11 * *
12 * This program is distributed in the hope that it will be useful, *
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15 * GNU General Public License for more details. *
16 * *
17 * You should have received a copy of the GNU General Public License *
18 * along with this program; if not, write to the *
19 * Free Software Foundation, Inc., *
20 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
21 ***************************************************************************/
22
23 #ifndef CHECKERS_H
24 #define CHECKERS_H
25
26
27 #include <QString>
28
29 #include "capture.h"
30
31 // do not change - hard coded
32 #define NONE 0
33 #define MAN1 1
34 #define KING1 2
35 #define FREE 3
36 #define KING2 4
37 #define MAN2 5
38 #define FULL 6
39
40 #define UL -6
41 #define UR -5
42 #define DL 5
43 #define DR 6
44
45
46 class Checkers
47 {
48 public:
49 Checkers();
50 virtual ~Checkers() {}
51
52 bool setup(int setupboard[]);
53 virtual bool go1(int from, int to)=0;
54
55 void go2();
56
57 void setSkill(int i) { levelmax=i; };
58 int skill() const { return levelmax; }
59 virtual int type() const = 0;
60
61 int item(int i) const { return board[internal(i)]; }
62 void setItem(int i, int item) { board[internal(i)] = item; }
63
64 // string representation of the game board.
65 // set rotate to switch player sides.
66 QString toString(bool rotate) const;
67 bool fromString(const QString&);
68
69 // checks for a capture/move for particular stone in external
70 // representation. human player only.
71 bool canCapture1(int i) { return checkCapture1(internal(i)); }
72 bool canMove1(int i) { return checkMove1(internal(i)); }
73
74 bool checkMove1() const;
75 bool checkMove2() const;
76 virtual bool checkCapture1() const = 0;
77 virtual bool checkCapture2() const = 0;
78
79 bool checkCapture1(const int i) {
80 return ! getPossibleCapture(i)->isEmpty();
81 }
82
83 Captures* getPossibleCapture() const;
84
85 QString describeCapture(bool, Captures*) const;
86
87 virtual QString getFieldNotation(int, bool) const = 0;
88
89 protected:
90 bool checkMove1(int) const;
91 virtual Captures* getPossibleCapture(int) const = 0;
92
93 int level; // Current level
94 int levelmax; // Maximum level
95
96 int turn();
97 void turn(int&, bool capture=false);
98
99 int to;
100 int board[54];
101 int bestboard[54];
102 int bestcounter;
103
104 virtual void kingMove2(int,int &)=0;
105
106 virtual bool manCapture2(int,int &)=0;
107 virtual bool kingCapture2(int,int,int &)=0;
108
109 virtual bool manCapture1(int,int,bool &)=0;
110 virtual bool kingCapture1(int,int,bool &)=0;
111
112 int internal(int) const; // Return internal board position
113 int external(int) const; // Return extenal board position
114 };
115
116
117 #endif