[go: up one dir, main page]

Menu

[r1125]: / src / protector.h  Maximize  Restore  History

Download this file

253 lines (213 with data), 6.6 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
/*
Protector -- a UCI chess engine
Copyright (C) 2009-2010 Raimund Heid (Raimund_Heid@yahoo.com)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _protector_h_
#define _protector_h_
#include "tools.h"
/* #define USE_BOOK 1 */
/*
* Constants
*/
#define MAX_THREADS 32
#define DEPTH_RESOLUTION 2
#define _64_ 64
#define FALSE 0
#define TRUE 1
#define VALUE_MATED (-30000)
#define VALUE_ALMOST_MATED (-29900)
#define MAX_MOVES_PER_POSITION (250)
/* #define SEND_HASH_ENTRIES 1 */
extern int _distance[_64_][_64_];
extern int _horizontalDistance[_64_][_64_];
extern int _verticalDistance[_64_][_64_];
extern int _taxiDistance[_64_][_64_];
extern const int colorSign[2];
extern int pieceIndex[16];
extern int debugOutput;
extern int numPvs; /* for multi pv mode; default is 1 */
#define MAX_NUM_PV 8
/**
* Types
*/
typedef unsigned char BYTE;
typedef char INT8;
typedef unsigned char UINT8;
typedef short INT16;
typedef unsigned short UINT16;
typedef int INT32;
typedef unsigned int UINT32;
#define ULONG_ZERO 0
/* #define ICC */
#define wV(x,w) (((x)*(w))/256)
typedef long long INT64;
typedef unsigned long long UINT64;
typedef unsigned char bool;
extern UINT64 statCount1, statCount2;
extern const char *programVersionNumber;
typedef enum
{
WHITE, BLACK
}
Color;
typedef enum
{
DARK, LIGHT, ALL
}
SquareColor;
typedef enum
{
RESULT_UNKNOWN, RESULT_WHITE_WINS, RESULT_DRAW, RESULT_BLACK_WINS
}
GameResult;
typedef enum
{
TS_FALSE = 0, TS_UNKNOWN = 1, TS_TRUE = 2
}
TriStateType;
/* Gameresult values */
#define GAMERESULT_UNKNOWN "*"
#define GAMERESULT_WHITE_WINS "1-0"
#define GAMERESULT_DRAW "1/2-1/2"
#define GAMERESULT_BLACK_WINS "0-1"
/* Game termination reasons */
#define GAMERESULT_WHITE_MATES "White mates"
#define GAMERESULT_BLACK_MATES "Black mates"
#define GAMERESULT_WHITE_RESIGNS "White resigns"
#define GAMERESULT_BLACK_RESIGNS "Black resigns"
#define GAMERESULT_WHITE_TIME_FORFEIT "White forfeits on time"
#define GAMERESULT_BLACK_TIME_FORFEIT "Black forfeits on time"
#define GAMERESULT_DRAW_AGREED "Draw agreed"
#define GAMERESULT_STALEMATE "Stalemate"
#define GAMERESULT_REPETITION "Draw by repetion"
#define GAMERESULT_50_MOVE_RULE "Draw by 50 move rule"
#define GAMERESULT_INSUFFICIENT_MATERIAL "Insufficient material"
typedef struct
{
char result[10];
char reason[128];
}
Gameresult;
#define PP_BLACK_PIECE 0x01
#define PP_SLIDING_PIECE 0x02
#define PP_ORTHOPIECE 0x04
#define PP_SPECIALPIECE 0x04
#define PP_DIAPIECE 0x08
#define PP_NONKINGPIECE 0x08
typedef enum
{
NO_PIECETYPE = 0x00,
KING = PP_SPECIALPIECE,
QUEEN = PP_SLIDING_PIECE | PP_ORTHOPIECE | PP_DIAPIECE,
ROOK = PP_SLIDING_PIECE | PP_ORTHOPIECE,
BISHOP = PP_SLIDING_PIECE | PP_DIAPIECE,
KNIGHT = PP_NONKINGPIECE,
PAWN = PP_SPECIALPIECE | PP_NONKINGPIECE
}
PieceType;
typedef enum
{
NO_PIECE = 0x00,
WHITE_KING = KING,
WHITE_QUEEN = QUEEN,
WHITE_ROOK = ROOK,
WHITE_BISHOP = BISHOP,
WHITE_KNIGHT = KNIGHT,
WHITE_PAWN = PAWN,
BLACK_KING = BLACK | KING,
BLACK_QUEEN = BLACK | QUEEN,
BLACK_ROOK = BLACK | ROOK,
BLACK_BISHOP = BLACK | BISHOP,
BLACK_KNIGHT = BLACK | KNIGHT,
BLACK_PAWN = BLACK | PAWN
}
Piece;
typedef enum
{
WHITE_BISHOP_DARK = 2,
WHITE_BISHOP_LIGHT = WHITE_BISHOP,
BLACK_BISHOP_DARK = 3,
BLACK_BISHOP_LIGHT = BLACK_BISHOP
}
BishopPiece;
typedef enum
{
NO_SQUARE = -1,
A1, B1, C1, D1, E1, F1, G1, H1,
A2, B2, C2, D2, E2, F2, G2, H2,
A3, B3, C3, D3, E3, F3, G3, H3,
A4, B4, C4, D4, E4, F4, G4, H4,
A5, B5, C5, D5, E5, F5, G5, H5,
A6, B6, C6, D6, E6, F6, G6, H6,
A7, B7, C7, D7, E7, F7, G7, H7,
A8, B8, C8, D8, E8, F8, G8, H8
}
Square;
typedef enum
{
FILE_A, FILE_B, FILE_C, FILE_D, FILE_E, FILE_F, FILE_G, FILE_H
}
File;
typedef enum
{
RANK_1, RANK_2, RANK_3, RANK_4, RANK_5, RANK_6, RANK_7, RANK_8
}
Rank;
typedef enum
{
NO_CASTLINGS = 0,
WHITE_00 = 1, WHITE_000 = 2,
BLACK_00 = 4, BLACK_000 = 8
}
Castlings;
/**
* Functions
*/
#define pieceColor( piece ) ((Color) ( (piece) & 0x01 ))
#define pieceType( piece ) ((PieceType) ( (piece) & 0x0E ))
#define opponents( piece1, piece2 ) ( ((piece1)^(piece2)) & 0x01 )
#define squareColor( square ) ((SquareColor)( (file(square) + rank(square)) % 2 ))
#define file( square ) ((File) ( (square) & 0x07 ))
#define rank( square ) ((Rank) ( (square) >> 3 ))
#define colorRank( color, square ) (Rank) \
( (color) == WHITE ? rank(square) : 7-rank(square) )
#define squareIsValid( square ) ( (square) >= A1 && (square) <= H8 )
#define getSquare( file, rank ) ((Square) ( (file) + ((rank) << 3) ))
#define getFlippedSquare( square ) \
( getSquare ( file(square), (RANK_8-rank(square)) ) )
#define getHflippedSquare( square ) \
( getSquare ( (FILE_H-file(square)), rank(square) ) )
#define fileName( file ) ( 'a' + (file) )
#define rankName( rank ) ( '1' + (rank) )
#define distance(sq1,sq2) (_distance[(sq1)][(sq2)])
#define horizontalDistance(sq1,sq2) (_horizontalDistance[(sq1)][(sq2)])
#define verticalDistance(sq1,sq2) (_verticalDistance[(sq1)][(sq2)])
#define taxiDistance(sq1,sq2) (_taxiDistance[(sq1)][(sq2)])
#define hasCastlings(color, castlings)(castlingsOfColor[(color)]&(castlings))
#define upward(color, square)((square)+((color)==WHITE?8:-8))
#define downward(color, square)((square)+((color)==WHITE?-8:8))
/**
* Iteration shortcuts
*/
#define ITERATE(sq) for ( sq = A1; sq <= H8; sq++ )
typedef struct
{
bool processModuleTest;
bool xboardMode;
bool dumpEvaluation;
char *testfile, *bookfile;
char *tablebasePath;
}
CommandlineOptions;
extern CommandlineOptions commandlineOptions;
#endif