/* board.h * */ /* icds - Internet Checkers and Draughts Server Copyright (c) 1997 by Michael Rohrer fics - An internet chess server. Copyright (C) 1993 Richard V. Nash 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 2 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. */ /* Revision history: name email yy/mm/dd Change Richard Nash 93/10/22 Created Michael Rohrer 97/05/01 Modified */ #ifndef _BOARD_H #define _BOARD_H #define WHITE 0x00 #define BLACK 0x80 #define CString( c ) (((c) == WHITE) ? "White" : "Black" ) #define CToggle( c ) (((c) == BLACK) ? WHITE : BLACK ) /* These are indexes into an array so their values are not arbitrary */ #define NOPIECE 0x00 #define PIECE 0x01 #define KING 0x02 /* #define PPIECE 0x03 #define PKING 0x04 */ #define MAX_BOARD_STRING_LEGTH 1280 /* Abitrarily 80 * 16 */ #define MAX_STYLES 5 #define W_PIECE (PIECE | WHITE) #define W_KING (KING | WHITE) /* #define W_PPIECE (PPIECE | WHITE) #define W_PKING (PKING | WHITE) */ #define B_PIECE (PIECE | BLACK) #define B_KING (KING | BLACK) /* #define B_PPIECE (PPIECE | BLACK) #define B_PKING (PKING | BLACK) */ #define isblack(p) (((p) & BLACK) == BLACK) #define iswhite(p) ((((p) & BLACK) == WHITE) && (p != NOPIECE)) #define iscolor(p,color) (((p) & BLACK) == (color)) /* for replacing !iscolor and having separate check for nopiece */ #define isnotcolor(p,color) ((((p) & BLACK) != (color)) && (p != NOPIECE)) #define piecetype(p) ((p) & 0x0f) #define colorval(p) ((p) & 0x80) #define square_color(r,f) ((((r)+(f)) & 0x01) ? BLACK : WHITE) extern int pieceValues[5]; /* Treated as [file][rank] */ typedef int board_t[10][10]; typedef struct _game_state_t { board_t board; /* For draws */ int lastIrreversable; int onMove; int moveNum; /* Game num not saved, must be restored when read */ int gameNum; } game_state_t; typedef struct _square { int file, rank; } spot; typedef struct _move_t { int color; spot square[10]; /* int fromFile, fromRank, toFile, toRank; */ int capFile, capRank; int pieceCaptured; char moveString[30]; char algString[30]; unsigned char FENpos[74]; /* This replaces the boardList. */ unsigned atTime; unsigned tookTime; } move_t; #define MoveToHalfMove( gs ) ((((gs)->moveNum - 1) * 2) + (((gs)->onMove == WHITE) ? 0 : 1)) extern char *wpstring[]; extern char *bpstring[]; extern int board_init(game_state_t *, int); extern void board_calc_strength(game_state_t *, int *, int *); extern char *board_to_string(char *, char *, int, int, game_state_t *, move_t *, int, int, int, int); extern char *move_and_time(move_t *); extern int board_load_british(game_state_t *); extern int board_load_pool(game_state_t *); extern int board_load_spanish(game_state_t *); extern int board_load_polish(game_state_t *); /* extern int board_read_file(char *, game_state_t *); */ extern int fgetc(); #endif