2 Copyright (c) 1993 Richard V. Nash.
3 Copyright (C) Andrew Tridgell 2002
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 #define CString( c ) ( ((c) == WHITE) ? "White" : "Black" )
27 #define CToggle( c ) ( ((c) == BLACK) ? WHITE : BLACK )
29 /* These will go into an array */
39 #define MAX_BOARD_STRING_LEGTH 1280 /* Abitrarily 80 * 16 */
42 #define W_PAWN (PAWN | WHITE)
43 #define W_KNIGHT (KNIGHT | WHITE)
44 #define W_BISHOP (BISHOP | WHITE)
45 #define W_ROOK (ROOK | WHITE)
46 #define W_QUEEN (QUEEN | WHITE)
47 #define W_KING (KING | WHITE)
49 #define B_PAWN (PAWN | BLACK)
50 #define B_KNIGHT (KNIGHT | BLACK)
51 #define B_BISHOP (BISHOP | BLACK)
52 #define B_ROOK (ROOK | BLACK)
53 #define B_QUEEN (QUEEN | BLACK)
54 #define B_KING (KING | BLACK)
56 #define isblack(p) ((p) & BLACK)
57 #define iswhite(p) (!isblack(p))
58 #define iscolor(p,color) (((p) & BLACK) == (color))
59 #define piecetype(p) ((p) & 0x7f)
60 #define colorval(p) ((p) & 0x80)
61 #define square_color(r,f) ((((r)+(f)) & 0x01) ? BLACK : WHITE)
63 extern int pieceValues[7];
65 /* Treated as [file][rank] */
66 typedef int board_t[8][8];
68 GENSTRUCT struct game_state_t {
73 unsigned char wkmoved, wqrmoved, wkrmoved;
74 unsigned char bkmoved, bqrmoved, bkrmoved;
76 int ep_possible[2][8];
81 /* Game num not saved, must be restored when read */
87 /* bughouse: if a drop move, then fromFile is ALG_DROP and fromRank is piece */
89 GENSTRUCT struct move_t {
91 int fromFile, fromRank;
95 int enPassant; /* 0 = no, 1=higher -1= lower */
96 int doublePawn; /* Only used for board display */
97 char moveString[8]; _NULLTERM
98 char algString[8]; _NULLTERM
99 unsigned char FENpos[74]; _NULLTERM
103 /* these are used when examining a game */
108 #define MoveToHalfMove( gs ) ((((gs)->moveNum - 1) * 2) + (((gs)->onMove == WHITE) ? 0 : 1))
110 extern const char *wpstring[];
111 extern const char *bpstring[];
113 /* the FEN for the default initial position */
114 #define INITIAL_FEN "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w"