all-up-in-your-elo 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/Gemfile +14 -0
- data/Gemfile.lock +22 -0
- data/LICENSE.txt +20 -0
- data/README.rdoc +42 -0
- data/Rakefile +54 -0
- data/VERSION +1 -0
- data/all-up-in-your-elo.gemspec +148 -0
- data/ext/bayeselo/.gitignore +4 -0
- data/ext/bayeselo/CBradleyTerry.cpp +670 -0
- data/ext/bayeselo/CBradleyTerry.h +137 -0
- data/ext/bayeselo/CCDistribution.cpp +135 -0
- data/ext/bayeselo/CCDistribution.h +44 -0
- data/ext/bayeselo/CCDistributionCUI.cpp +104 -0
- data/ext/bayeselo/CCDistributionCUI.h +38 -0
- data/ext/bayeselo/CCondensedResults.cpp +253 -0
- data/ext/bayeselo/CCondensedResults.h +64 -0
- data/ext/bayeselo/CDiscretization.h +40 -0
- data/ext/bayeselo/CDistribution.cpp +123 -0
- data/ext/bayeselo/CDistribution.h +58 -0
- data/ext/bayeselo/CDistributionCollection.cpp +34 -0
- data/ext/bayeselo/CDistributionCollection.h +29 -0
- data/ext/bayeselo/CEloRatingCUI.cpp +1046 -0
- data/ext/bayeselo/CEloRatingCUI.h +67 -0
- data/ext/bayeselo/CIndirectCompare.h +28 -0
- data/ext/bayeselo/CJointBayesian.cpp +111 -0
- data/ext/bayeselo/CJointBayesian.h +38 -0
- data/ext/bayeselo/CLUDecomposition.cpp +154 -0
- data/ext/bayeselo/CLUDecomposition.h +36 -0
- data/ext/bayeselo/CMatrix.cpp +48 -0
- data/ext/bayeselo/CMatrix.h +35 -0
- data/ext/bayeselo/CMatrixIO.cpp +27 -0
- data/ext/bayeselo/CMatrixIO.h +17 -0
- data/ext/bayeselo/CPredictionCUI.cpp +393 -0
- data/ext/bayeselo/CPredictionCUI.h +50 -0
- data/ext/bayeselo/CResultSet.cpp +245 -0
- data/ext/bayeselo/CResultSet.h +50 -0
- data/ext/bayeselo/CResultSetCUI.cpp +355 -0
- data/ext/bayeselo/CResultSetCUI.h +44 -0
- data/ext/bayeselo/CTimeIO.cpp +58 -0
- data/ext/bayeselo/CTimeIO.h +19 -0
- data/ext/bayeselo/CVector.cpp +110 -0
- data/ext/bayeselo/CVector.h +42 -0
- data/ext/bayeselo/EloDataFromFile.cpp +120 -0
- data/ext/bayeselo/EloDataFromFile.h +21 -0
- data/ext/bayeselo/README +8 -0
- data/ext/bayeselo/ReadLineToString.cpp +32 -0
- data/ext/bayeselo/ReadLineToString.h +18 -0
- data/ext/bayeselo/chtime.cpp +56 -0
- data/ext/bayeselo/chtime.h +61 -0
- data/ext/bayeselo/chtimer.h +27 -0
- data/ext/bayeselo/clktimer.cpp +178 -0
- data/ext/bayeselo/clktimer.h +29 -0
- data/ext/bayeselo/consolui.cpp +538 -0
- data/ext/bayeselo/consolui.h +154 -0
- data/ext/bayeselo/const.cpp +79 -0
- data/ext/bayeselo/const.h +42 -0
- data/ext/bayeselo/date.cpp +96 -0
- data/ext/bayeselo/date.h +44 -0
- data/ext/bayeselo/debug.h +58 -0
- data/ext/bayeselo/elomain.cpp +26 -0
- data/ext/bayeselo/eloratings.cpp +76 -0
- data/ext/bayeselo/extconf.rb +6 -0
- data/ext/bayeselo/list.h +367 -0
- data/ext/bayeselo/listi.h +125 -0
- data/ext/bayeselo/move.cpp +249 -0
- data/ext/bayeselo/move.h +139 -0
- data/ext/bayeselo/pgn.h +62 -0
- data/ext/bayeselo/pgnlex.cpp +432 -0
- data/ext/bayeselo/pgnlex.h +105 -0
- data/ext/bayeselo/pgnstr.cpp +126 -0
- data/ext/bayeselo/piece.h +44 -0
- data/ext/bayeselo/player.h +31 -0
- data/ext/bayeselo/position.h +89 -0
- data/ext/bayeselo/random.cpp +114 -0
- data/ext/bayeselo/random.h +63 -0
- data/ext/bayeselo/readstr.cpp +51 -0
- data/ext/bayeselo/readstr.h +19 -0
- data/ext/bayeselo/square.h +61 -0
- data/ext/bayeselo/str.cpp +81 -0
- data/ext/bayeselo/str.h +71 -0
- data/ext/bayeselo/version.cpp +30 -0
- data/ext/bayeselo/version.h +28 -0
- data/ext/bayeselo/version_number.h +1 -0
- data/lib/elo_ratings.rb +9 -0
- data/lib/elo_ratings/c_bayeselo.rb +5 -0
- data/lib/elo_ratings/results.rb +41 -0
- data/test/elo_ratings/test_c_bayeselo.rb +84 -0
- data/test/elo_ratings/test_results.rb +41 -0
- data/test/helper.rb +19 -0
- metadata +233 -0
@@ -0,0 +1,125 @@
|
|
1
|
+
////////////////////////////////////////////////////////////////////////////
|
2
|
+
//
|
3
|
+
// listi.h
|
4
|
+
//
|
5
|
+
// CListIterator<class T> template definition
|
6
|
+
//
|
7
|
+
// Remi Coulom
|
8
|
+
//
|
9
|
+
// june 1996
|
10
|
+
//
|
11
|
+
////////////////////////////////////////////////////////////////////////////
|
12
|
+
#ifndef LISTI_H
|
13
|
+
#define LISTI_H
|
14
|
+
|
15
|
+
#include "list.h" // CList template
|
16
|
+
|
17
|
+
////////////////////////////////////////////////////////////////////////////
|
18
|
+
// CListIterator class definition
|
19
|
+
////////////////////////////////////////////////////////////////////////////
|
20
|
+
template<class T>
|
21
|
+
class CListIterator // listi
|
22
|
+
{
|
23
|
+
private: //////////////////////////////////////////////////////////////////
|
24
|
+
CList<T> *plt;
|
25
|
+
CListCell<T> *pcellCurrent;
|
26
|
+
CListCell<T> *pcellPrevious;
|
27
|
+
|
28
|
+
public: ///////////////////////////////////////////////////////////////////
|
29
|
+
CListIterator(CList<T>& ltInit);
|
30
|
+
|
31
|
+
void Increment();
|
32
|
+
void Remove();
|
33
|
+
void Insert();
|
34
|
+
void Reset();
|
35
|
+
|
36
|
+
T& Value();
|
37
|
+
int IsFirst() const {return !pcellPrevious;}
|
38
|
+
int IsAtTheEnd() const {return !pcellCurrent;}
|
39
|
+
};
|
40
|
+
|
41
|
+
////////////////////////////////////////////////////////////////////////////
|
42
|
+
// Constructor
|
43
|
+
////////////////////////////////////////////////////////////////////////////
|
44
|
+
template<class T>
|
45
|
+
CListIterator<T>::CListIterator(CList<T>& ltInit)
|
46
|
+
{
|
47
|
+
plt = <Init;
|
48
|
+
pcellPrevious = 0;
|
49
|
+
pcellCurrent = ltInit.pcellFirst;
|
50
|
+
}
|
51
|
+
|
52
|
+
////////////////////////////////////////////////////////////////////////////
|
53
|
+
// Resets an iterator to the beginning of its list
|
54
|
+
////////////////////////////////////////////////////////////////////////////
|
55
|
+
template<class T>
|
56
|
+
void CListIterator<T>::Reset()
|
57
|
+
{
|
58
|
+
pcellPrevious = 0;
|
59
|
+
pcellCurrent = plt->pcellFirst;
|
60
|
+
}
|
61
|
+
|
62
|
+
////////////////////////////////////////////////////////////////////////////
|
63
|
+
// Moves to the next position in a list
|
64
|
+
////////////////////////////////////////////////////////////////////////////
|
65
|
+
template<class T>
|
66
|
+
INLINE
|
67
|
+
void CListIterator<T>::Increment()
|
68
|
+
{
|
69
|
+
ASSERT(!IsAtTheEnd());
|
70
|
+
pcellPrevious = pcellCurrent;
|
71
|
+
pcellCurrent = pcellCurrent->Next();
|
72
|
+
}
|
73
|
+
|
74
|
+
////////////////////////////////////////////////////////////////////////////
|
75
|
+
// Insert one cell at the current position
|
76
|
+
////////////////////////////////////////////////////////////////////////////
|
77
|
+
template<class T>
|
78
|
+
void CListIterator<T>::Insert()
|
79
|
+
{
|
80
|
+
if (!pcellPrevious)
|
81
|
+
{
|
82
|
+
plt->Add();
|
83
|
+
pcellCurrent = plt->pcellFirst;
|
84
|
+
}
|
85
|
+
else
|
86
|
+
{
|
87
|
+
CListCell<T> *pcellNew = plt->AllocateCell();
|
88
|
+
pcellNew->Link(pcellCurrent);
|
89
|
+
pcellPrevious->Link(pcellNew);
|
90
|
+
pcellCurrent = pcellNew;
|
91
|
+
}
|
92
|
+
}
|
93
|
+
|
94
|
+
////////////////////////////////////////////////////////////////////////////
|
95
|
+
// Removes one cell from the list
|
96
|
+
////////////////////////////////////////////////////////////////////////////
|
97
|
+
template<class T>
|
98
|
+
void CListIterator<T>::Remove()
|
99
|
+
{
|
100
|
+
ASSERT(!IsAtTheEnd());
|
101
|
+
|
102
|
+
{
|
103
|
+
CListCell<T> *pcell = pcellCurrent;
|
104
|
+
pcellCurrent = pcellCurrent->Next();
|
105
|
+
plt->FreeCell(pcell);
|
106
|
+
}
|
107
|
+
|
108
|
+
if (pcellPrevious)
|
109
|
+
pcellPrevious->Link(pcellCurrent);
|
110
|
+
else
|
111
|
+
plt->pcellFirst = pcellCurrent;
|
112
|
+
}
|
113
|
+
|
114
|
+
////////////////////////////////////////////////////////////////////////////
|
115
|
+
// Reads the value contained by the current cell
|
116
|
+
////////////////////////////////////////////////////////////////////////////
|
117
|
+
template<class T>
|
118
|
+
INLINE
|
119
|
+
T& CListIterator<T>::Value()
|
120
|
+
{
|
121
|
+
ASSERT(!IsAtTheEnd());
|
122
|
+
return pcellCurrent->Value();
|
123
|
+
}
|
124
|
+
|
125
|
+
#endif
|
@@ -0,0 +1,249 @@
|
|
1
|
+
////////////////////////////////////////////////////////////////////////////
|
2
|
+
//
|
3
|
+
// move.cpp
|
4
|
+
//
|
5
|
+
// CMove class
|
6
|
+
//
|
7
|
+
// Remi Coulom
|
8
|
+
//
|
9
|
+
// june 1996
|
10
|
+
//
|
11
|
+
////////////////////////////////////////////////////////////////////////////
|
12
|
+
#include <cstring>
|
13
|
+
#include <iostream>
|
14
|
+
|
15
|
+
#include "move.h"
|
16
|
+
#include "square.h" // CSquare
|
17
|
+
#include "player.h" // CPlayer
|
18
|
+
#include "piece.h" // CPiece
|
19
|
+
#include "position.h" // CPosition
|
20
|
+
|
21
|
+
using namespace std;
|
22
|
+
|
23
|
+
CMove CMove::moveNull(0, 0, 0, 0);
|
24
|
+
|
25
|
+
////////////////////////////////////////////////////////////////////////////
|
26
|
+
// Function to write a move string
|
27
|
+
// psz must point to a string with at least MaxMoveString characters
|
28
|
+
////////////////////////////////////////////////////////////////////////////
|
29
|
+
#define ADD(c) do {*psz = (c); psz++;} while(0)
|
30
|
+
void CMove::MakeString(char *psz, int Notation) const
|
31
|
+
{
|
32
|
+
//
|
33
|
+
// Null move
|
34
|
+
//
|
35
|
+
if (!sqFrom && !sqTo)
|
36
|
+
{
|
37
|
+
ADD('n');
|
38
|
+
ADD('u');
|
39
|
+
ADD('l');
|
40
|
+
ADD('l');
|
41
|
+
ADD(0);
|
42
|
+
return;
|
43
|
+
}
|
44
|
+
|
45
|
+
static const char PieceLetter[] = "?KQRBNP";
|
46
|
+
static int Conversion[] = {1, 2, 3, 3, 4, 4, 5, 5, 6};
|
47
|
+
|
48
|
+
if (Notation == Basic || Notation == ChessBase)
|
49
|
+
{
|
50
|
+
ADD('a' + (sqFrom & 7));
|
51
|
+
ADD('1' + (sqFrom / 8));
|
52
|
+
ADD('a' + (sqTo & 7));
|
53
|
+
ADD('1' + (sqTo / 8));
|
54
|
+
|
55
|
+
if (ucType & Promotion)
|
56
|
+
{
|
57
|
+
if (Notation == Basic)
|
58
|
+
ADD('=');
|
59
|
+
ADD(PieceLetter[Conversion[ucType & 0x0f]]);
|
60
|
+
}
|
61
|
+
|
62
|
+
if (ucType == ep && Notation == Basic)
|
63
|
+
{
|
64
|
+
ADD('e');
|
65
|
+
ADD('p');
|
66
|
+
}
|
67
|
+
|
68
|
+
if ((ucType == OO || ucType == OOO) && Notation == Basic)
|
69
|
+
ADD('c');
|
70
|
+
}
|
71
|
+
else
|
72
|
+
{
|
73
|
+
//
|
74
|
+
// Short castle
|
75
|
+
//
|
76
|
+
if (ucType == OO)
|
77
|
+
{
|
78
|
+
ADD('O');
|
79
|
+
ADD('-');
|
80
|
+
ADD('O');
|
81
|
+
}
|
82
|
+
|
83
|
+
//
|
84
|
+
// Long castle
|
85
|
+
//
|
86
|
+
else if (ucType == OOO)
|
87
|
+
{
|
88
|
+
ADD('O');
|
89
|
+
ADD('-');
|
90
|
+
ADD('O');
|
91
|
+
ADD('-');
|
92
|
+
ADD('O');
|
93
|
+
}
|
94
|
+
|
95
|
+
//
|
96
|
+
// Other moves
|
97
|
+
//
|
98
|
+
else
|
99
|
+
{
|
100
|
+
//
|
101
|
+
// Origin square
|
102
|
+
//
|
103
|
+
if ((ucSAN & 0x07) == Pawn &&
|
104
|
+
(ucSAN & Capture) &&
|
105
|
+
Notation == StandardAlgebraic)
|
106
|
+
ADD('a' + (sqFrom & 7));
|
107
|
+
else if ((ucSAN & 0x07) != Pawn || Notation == LongAlgebraic)
|
108
|
+
{
|
109
|
+
if ((ucSAN & 0x07) != Pawn)
|
110
|
+
ADD(PieceLetter[ucSAN & 0x07]);
|
111
|
+
if ((ucSAN & File) || Notation == LongAlgebraic)
|
112
|
+
ADD('a' + (sqFrom & 7));
|
113
|
+
if ((ucSAN & Rank) || Notation == LongAlgebraic)
|
114
|
+
ADD('1' + (sqFrom / 8));
|
115
|
+
}
|
116
|
+
|
117
|
+
//
|
118
|
+
// Capture indication
|
119
|
+
//
|
120
|
+
if (ucSAN & Capture)
|
121
|
+
ADD('x');
|
122
|
+
else if (Notation == LongAlgebraic)
|
123
|
+
ADD('-');
|
124
|
+
|
125
|
+
//
|
126
|
+
// Destination square
|
127
|
+
//
|
128
|
+
ADD('a' + (sqTo & 7));
|
129
|
+
ADD('1' + (sqTo / 8));
|
130
|
+
|
131
|
+
//
|
132
|
+
// Promotions
|
133
|
+
//
|
134
|
+
if (ucType & Promotion)
|
135
|
+
{
|
136
|
+
ADD('=');
|
137
|
+
ADD(PieceLetter[Conversion[ucType & 0x0f]]);
|
138
|
+
}
|
139
|
+
}
|
140
|
+
|
141
|
+
//
|
142
|
+
// Check and mate
|
143
|
+
//
|
144
|
+
if (FullSANComputed())
|
145
|
+
{
|
146
|
+
if (ucSAN & Mate)
|
147
|
+
ADD('#');
|
148
|
+
else if (ucSAN & Check)
|
149
|
+
ADD('+');
|
150
|
+
}
|
151
|
+
}
|
152
|
+
|
153
|
+
//
|
154
|
+
// End of move string
|
155
|
+
//
|
156
|
+
ADD(0);
|
157
|
+
}
|
158
|
+
#undef ADD
|
159
|
+
|
160
|
+
////////////////////////////////////////////////////////////////////////////
|
161
|
+
// Function to parse a move string
|
162
|
+
// Return value : 0 when sucessfully parsed, 1 otherwise
|
163
|
+
////////////////////////////////////////////////////////////////////////////
|
164
|
+
int CMove::ParseString(const char *psz)
|
165
|
+
{
|
166
|
+
ucType = 0;
|
167
|
+
ucSAN = 0;
|
168
|
+
|
169
|
+
//
|
170
|
+
// null move
|
171
|
+
//
|
172
|
+
if (psz[0] == 'n' && psz[1] == 'u' && psz[2] == 'l' && psz[3] == 'l')
|
173
|
+
*this = moveNull;
|
174
|
+
|
175
|
+
//
|
176
|
+
// sqFrom and sqTo;
|
177
|
+
//
|
178
|
+
sqFrom = CSquare(psz);
|
179
|
+
sqTo = CSquare(psz + 2);
|
180
|
+
if (sqFrom > CSquare::h8 || sqTo > CSquare::h8)
|
181
|
+
return 1;
|
182
|
+
|
183
|
+
//
|
184
|
+
// Castling
|
185
|
+
//
|
186
|
+
if (psz[4] == 'c')
|
187
|
+
{
|
188
|
+
if (psz[2] == 'g')
|
189
|
+
ucType = CMove::OO;
|
190
|
+
else
|
191
|
+
ucType = CMove::OOO;
|
192
|
+
}
|
193
|
+
|
194
|
+
//
|
195
|
+
// Promotion
|
196
|
+
//
|
197
|
+
if (psz[4] == '=')
|
198
|
+
{
|
199
|
+
switch(psz[5])
|
200
|
+
{
|
201
|
+
case 'Q': ucType = Promotion | CPiece::Queen; break;
|
202
|
+
case 'R': ucType = Promotion | CPiece::Rook; break;
|
203
|
+
case 'B': ucType = Promotion | CPiece::Bishop; break;
|
204
|
+
case 'N': ucType = Promotion | CPiece::Knight; break;
|
205
|
+
}
|
206
|
+
}
|
207
|
+
|
208
|
+
//
|
209
|
+
// capture "en passant"
|
210
|
+
//
|
211
|
+
if (psz[4] == 'e')
|
212
|
+
ucType = ep;
|
213
|
+
|
214
|
+
return 0;
|
215
|
+
}
|
216
|
+
|
217
|
+
////////////////////////////////////////////////////////////////////////////
|
218
|
+
// output operator
|
219
|
+
////////////////////////////////////////////////////////////////////////////
|
220
|
+
ostream &operator<<(ostream &ostr, const CMove &move)
|
221
|
+
{
|
222
|
+
char szMove[CMove::MaxMoveString];
|
223
|
+
if (move.FullSANComputed())
|
224
|
+
move.MakeString(szMove, CMove::StandardAlgebraic);
|
225
|
+
else
|
226
|
+
move.MakeString(szMove, CMove::Basic);
|
227
|
+
return ostr << szMove;
|
228
|
+
}
|
229
|
+
|
230
|
+
////////////////////////////////////////////////////////////////////////////
|
231
|
+
// Function to get the gnuchess notation of a move
|
232
|
+
////////////////////////////////////////////////////////////////////////////
|
233
|
+
void CMove::GNUChessNotation(char *pszString) const
|
234
|
+
{
|
235
|
+
#define ADD(c) do {*pszString = c; pszString++;} while(0)
|
236
|
+
ADD('a' + (GetFrom() & 7));
|
237
|
+
ADD('1' + (GetFrom() / 8));
|
238
|
+
ADD('a' + (GetTo() & 7));
|
239
|
+
ADD('1' + (GetTo() / 8));
|
240
|
+
|
241
|
+
static const char PieceLetter[] = "?kqrbnp";
|
242
|
+
static int Conversion[] = {1, 2, 3, 3, 4, 4, 5, 5, 6};
|
243
|
+
|
244
|
+
if (GetType() & Promotion)
|
245
|
+
ADD(PieceLetter[Conversion[GetType() & 0x0f]]);
|
246
|
+
|
247
|
+
ADD(0);
|
248
|
+
#undef ADD
|
249
|
+
}
|
data/ext/bayeselo/move.h
ADDED
@@ -0,0 +1,139 @@
|
|
1
|
+
////////////////////////////////////////////////////////////////////////////
|
2
|
+
//
|
3
|
+
// move.h
|
4
|
+
//
|
5
|
+
// CMove class definition
|
6
|
+
//
|
7
|
+
// Remi Coulom
|
8
|
+
//
|
9
|
+
// june 1996
|
10
|
+
//
|
11
|
+
////////////////////////////////////////////////////////////////////////////
|
12
|
+
#ifndef MOVE_H
|
13
|
+
#define MOVE_H
|
14
|
+
|
15
|
+
#include <iostream>
|
16
|
+
|
17
|
+
class CPosition;
|
18
|
+
class CMove;
|
19
|
+
|
20
|
+
std::ostream &operator<<(std::ostream &ostr, const CMove &move);
|
21
|
+
|
22
|
+
class CMove // move
|
23
|
+
{
|
24
|
+
private: //////////////////////////////////////////////////////////////////
|
25
|
+
unsigned char sqFrom;
|
26
|
+
unsigned char sqTo;
|
27
|
+
unsigned char ucType;
|
28
|
+
unsigned char ucSAN;
|
29
|
+
|
30
|
+
public: ///////////////////////////////////////////////////////////////////
|
31
|
+
//
|
32
|
+
// Move type flags
|
33
|
+
//
|
34
|
+
enum
|
35
|
+
{
|
36
|
+
Normal = 0x00,
|
37
|
+
OO = 0x80,
|
38
|
+
OOO = 0x40,
|
39
|
+
ep = 0x20,
|
40
|
+
Promotion = 0x10
|
41
|
+
};
|
42
|
+
|
43
|
+
//
|
44
|
+
// SAN flags
|
45
|
+
//
|
46
|
+
enum
|
47
|
+
{
|
48
|
+
King = 0x01,
|
49
|
+
Queen = 0x02,
|
50
|
+
Rook = 0x03,
|
51
|
+
Bishop = 0x04,
|
52
|
+
Knight = 0x05,
|
53
|
+
Pawn = 0x06,
|
54
|
+
File = 0x08,
|
55
|
+
Rank = 0x10,
|
56
|
+
Capture = 0x20,
|
57
|
+
Check = 0x40,
|
58
|
+
Mate = 0x80,
|
59
|
+
Partial = Mate | File | Rank
|
60
|
+
|
61
|
+
// Mate without Check is impossible in a fully computed set of SAN flags
|
62
|
+
// This is the reason why mate without check is used as an indicator that
|
63
|
+
// the full SAN flags have not been computed
|
64
|
+
// (see 'int FullSANComputed() const')
|
65
|
+
|
66
|
+
};
|
67
|
+
|
68
|
+
//
|
69
|
+
// Notations
|
70
|
+
//
|
71
|
+
enum
|
72
|
+
{
|
73
|
+
StandardAlgebraic, // Only when FullSANComputed()
|
74
|
+
LongAlgebraic, // Partial SAN flags required
|
75
|
+
Basic, // Does not use ucSAN. No ppos required for parsing
|
76
|
+
ChessBase
|
77
|
+
};
|
78
|
+
|
79
|
+
//
|
80
|
+
// Maximum characters of move strings (counting '\0' at the end)
|
81
|
+
//
|
82
|
+
enum {MaxMoveString = 10};
|
83
|
+
|
84
|
+
//
|
85
|
+
// Constructors
|
86
|
+
//
|
87
|
+
CMove() {}
|
88
|
+
CMove(const char *psz) {ParseString(psz);}
|
89
|
+
|
90
|
+
CMove(unsigned char sqFromNew,
|
91
|
+
unsigned char sqToNew,
|
92
|
+
unsigned char ucTypeNew = Normal,
|
93
|
+
unsigned char ucSANNew = 0)
|
94
|
+
{
|
95
|
+
Set(sqFromNew, sqToNew, ucTypeNew, ucSANNew);
|
96
|
+
}
|
97
|
+
|
98
|
+
//
|
99
|
+
// Basic sets and gets
|
100
|
+
//
|
101
|
+
void SetFrom(unsigned char sq) {sqFrom = sq;}
|
102
|
+
void SetTo(unsigned char sq) {sqTo = sq;}
|
103
|
+
void SetType(unsigned char uc) {ucType = uc;}
|
104
|
+
void SetSAN(unsigned char uc) {ucSAN = uc;}
|
105
|
+
void AddSAN(unsigned char uc) {ucSAN |= uc;}
|
106
|
+
void Set(unsigned char sqFromNew,
|
107
|
+
unsigned char sqToNew,
|
108
|
+
unsigned char ucTypeNew = Normal,
|
109
|
+
unsigned char ucSANNew = 0)
|
110
|
+
{
|
111
|
+
SetFrom(sqFromNew);
|
112
|
+
SetTo(sqToNew);
|
113
|
+
SetType(ucTypeNew);
|
114
|
+
SetSAN(ucSANNew);
|
115
|
+
}
|
116
|
+
|
117
|
+
unsigned char GetFrom() const {return sqFrom;}
|
118
|
+
unsigned char GetTo() const {return sqTo;}
|
119
|
+
unsigned char GetType() const {return ucType;}
|
120
|
+
unsigned char GetSAN() const {return ucSAN;}
|
121
|
+
|
122
|
+
//
|
123
|
+
// Other functions
|
124
|
+
//
|
125
|
+
int FullSANComputed() const
|
126
|
+
{
|
127
|
+
return ucSAN && (!(ucSAN & Mate) || (ucSAN & Check));
|
128
|
+
}
|
129
|
+
int ParseString(const char *psz);
|
130
|
+
void MakeString(char *psz, int Notation = StandardAlgebraic) const;
|
131
|
+
void GNUChessNotation(char *pszString) const;
|
132
|
+
|
133
|
+
//
|
134
|
+
// Null move
|
135
|
+
//
|
136
|
+
static CMove moveNull;
|
137
|
+
};
|
138
|
+
|
139
|
+
#endif
|