Remove Whitespaces from chessbox
Remove 1616 Whitespaces from chessbox Change-Id: I84c0dbd4a177eba50b9f7427f5695ae4b266aa5e
This commit is contained in:
parent
324ad2483a
commit
37522ec63a
6 changed files with 1616 additions and 1616 deletions
|
@ -7,7 +7,7 @@
|
||||||
* \/ \/ \/ \/ \/
|
* \/ \/ \/ \/ \/
|
||||||
* $Id$
|
* $Id$
|
||||||
*
|
*
|
||||||
* Copyright (C) 2006 Miguel A. Arévalo
|
* Copyright (C) 2006 Miguel A. Arévalo
|
||||||
* Color graphics from eboard
|
* Color graphics from eboard
|
||||||
* GNUChess v2 chess engine Copyright (c) 1988 John Stanback
|
* GNUChess v2 chess engine Copyright (c) 1988 John Stanback
|
||||||
*
|
*
|
||||||
|
@ -20,7 +20,7 @@
|
||||||
* KIND, either express or implied.
|
* KIND, either express or implied.
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include "plugin.h"
|
#include "plugin.h"
|
||||||
|
|
||||||
#if (MEMORYSIZE > 8) /* Lowmem doesn't have playback in chessbox */
|
#if (MEMORYSIZE > 8) /* Lowmem doesn't have playback in chessbox */
|
||||||
|
@ -80,7 +80,7 @@ short plugin_mode;
|
||||||
|
|
||||||
/* level+1's string */
|
/* level+1's string */
|
||||||
const char *level_string[] = { "Level 1: 60 moves / 5 min" ,
|
const char *level_string[] = { "Level 1: 60 moves / 5 min" ,
|
||||||
"Level 2: 60 moves / 15 min" ,
|
"Level 2: 60 moves / 15 min" ,
|
||||||
"Level 3: 60 moves / 30 min" ,
|
"Level 3: 60 moves / 30 min" ,
|
||||||
"Level 4: 40 moves / 30 min" ,
|
"Level 4: 40 moves / 30 min" ,
|
||||||
"Level 5: 40 moves / 60 min" ,
|
"Level 5: 40 moves / 60 min" ,
|
||||||
|
@ -120,7 +120,7 @@ static void cb_drawboard (void) {
|
||||||
short r , c , x , y ;
|
short r , c , x , y ;
|
||||||
short l , piece , p_color ;
|
short l , piece , p_color ;
|
||||||
int b_color=1;
|
int b_color=1;
|
||||||
|
|
||||||
rb->lcd_clear_display();
|
rb->lcd_clear_display();
|
||||||
|
|
||||||
for (r = 0; r < 8; r++) {
|
for (r = 0; r < 8; r++) {
|
||||||
|
@ -132,8 +132,8 @@ static void cb_drawboard (void) {
|
||||||
if ( piece == no_piece ) {
|
if ( piece == no_piece ) {
|
||||||
rb->lcd_bitmap_part ( chessbox_pieces , 0 ,
|
rb->lcd_bitmap_part ( chessbox_pieces , 0 ,
|
||||||
TILE_HEIGHT * b_color ,
|
TILE_HEIGHT * b_color ,
|
||||||
STRIDE( SCREEN_MAIN,
|
STRIDE( SCREEN_MAIN,
|
||||||
BMPWIDTH_chessbox_pieces,
|
BMPWIDTH_chessbox_pieces,
|
||||||
BMPHEIGHT_chessbox_pieces) ,
|
BMPHEIGHT_chessbox_pieces) ,
|
||||||
XOFS + x*TILE_WIDTH ,
|
XOFS + x*TILE_WIDTH ,
|
||||||
YOFS + ( 7 - y )*TILE_HEIGHT ,
|
YOFS + ( 7 - y )*TILE_HEIGHT ,
|
||||||
|
@ -146,8 +146,8 @@ static void cb_drawboard (void) {
|
||||||
4 * TILE_HEIGHT * ( piece - 1 ) +
|
4 * TILE_HEIGHT * ( piece - 1 ) +
|
||||||
2 * TILE_HEIGHT * p_color +
|
2 * TILE_HEIGHT * p_color +
|
||||||
TILE_HEIGHT * b_color ,
|
TILE_HEIGHT * b_color ,
|
||||||
STRIDE( SCREEN_MAIN,
|
STRIDE( SCREEN_MAIN,
|
||||||
BMPWIDTH_chessbox_pieces,
|
BMPWIDTH_chessbox_pieces,
|
||||||
BMPHEIGHT_chessbox_pieces) ,
|
BMPHEIGHT_chessbox_pieces) ,
|
||||||
XOFS + x*TILE_WIDTH ,
|
XOFS + x*TILE_WIDTH ,
|
||||||
YOFS + (7 - y)*TILE_HEIGHT ,
|
YOFS + (7 - y)*TILE_HEIGHT ,
|
||||||
|
@ -158,7 +158,7 @@ static void cb_drawboard (void) {
|
||||||
}
|
}
|
||||||
b_color = (b_color == 1) ? 0 : 1 ;
|
b_color = (b_color == 1) ? 0 : 1 ;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* draw board limits */
|
/* draw board limits */
|
||||||
#if (LCD_WIDTH > TILE_WIDTH*8) && (LCD_HEIGHT > TILE_HEIGHT*8)
|
#if (LCD_WIDTH > TILE_WIDTH*8) && (LCD_HEIGHT > TILE_HEIGHT*8)
|
||||||
rb->lcd_drawrect(XOFS - 1, YOFS - 1, TILE_WIDTH*8 + 2, TILE_HEIGHT*8 + 2);
|
rb->lcd_drawrect(XOFS - 1, YOFS - 1, TILE_WIDTH*8 + 2, TILE_HEIGHT*8 + 2);
|
||||||
|
@ -186,7 +186,7 @@ static void cb_switch ( short x , short y ) {
|
||||||
/* ---- callback for capturing interaction while thinking ---- */
|
/* ---- callback for capturing interaction while thinking ---- */
|
||||||
static void cb_wt_callback ( void ) {
|
static void cb_wt_callback ( void ) {
|
||||||
int button = BUTTON_NONE;
|
int button = BUTTON_NONE;
|
||||||
|
|
||||||
wt_command = COMMAND_NOP;
|
wt_command = COMMAND_NOP;
|
||||||
button = rb->button_get(false);
|
button = rb->button_get(false);
|
||||||
switch (button) {
|
switch (button) {
|
||||||
|
@ -270,7 +270,7 @@ static void cb_saveposition ( void ) {
|
||||||
int fd;
|
int fd;
|
||||||
short sq,i,c;
|
short sq,i,c;
|
||||||
unsigned short temp;
|
unsigned short temp;
|
||||||
|
|
||||||
rb->splash ( 0 , "Saving position" );
|
rb->splash ( 0 , "Saving position" );
|
||||||
|
|
||||||
fd = rb->open(SAVE_FILE, O_WRONLY|O_CREAT, 0666);
|
fd = rb->open(SAVE_FILE, O_WRONLY|O_CREAT, 0666);
|
||||||
|
@ -323,7 +323,7 @@ static void cb_restoreposition ( void ) {
|
||||||
int fd;
|
int fd;
|
||||||
short sq;
|
short sq;
|
||||||
unsigned short m;
|
unsigned short m;
|
||||||
|
|
||||||
if ( (fd = rb->open(SAVE_FILE, O_RDONLY)) >= 0 ) {
|
if ( (fd = rb->open(SAVE_FILE, O_RDONLY)) >= 0 ) {
|
||||||
rb->splash ( 0 , "Loading position" );
|
rb->splash ( 0 , "Loading position" );
|
||||||
rb->read(fd, &(computer), sizeof(computer));
|
rb->read(fd, &(computer), sizeof(computer));
|
||||||
|
@ -393,10 +393,10 @@ static int cb_menu_viewer(void)
|
||||||
int selection;
|
int selection;
|
||||||
int result = 0;
|
int result = 0;
|
||||||
bool menu_quit = false;
|
bool menu_quit = false;
|
||||||
|
|
||||||
MENUITEM_STRINGLIST(menu,"Chessbox Menu",NULL,"Restart Game",
|
MENUITEM_STRINGLIST(menu,"Chessbox Menu",NULL,"Restart Game",
|
||||||
"Select Other Game", "Quit");
|
"Select Other Game", "Quit");
|
||||||
|
|
||||||
while(!menu_quit)
|
while(!menu_quit)
|
||||||
{
|
{
|
||||||
switch(rb->do_menu(&menu, &selection, NULL, false))
|
switch(rb->do_menu(&menu, &selection, NULL, false))
|
||||||
|
@ -422,7 +422,7 @@ static int cb_menu_viewer(void)
|
||||||
static struct cb_command cb_get_viewer_command (void) {
|
static struct cb_command cb_get_viewer_command (void) {
|
||||||
int button;
|
int button;
|
||||||
struct cb_command result = { 0, {0,0,0,0,0}, 0 };
|
struct cb_command result = { 0, {0,0,0,0,0}, 0 };
|
||||||
|
|
||||||
/* main loop */
|
/* main loop */
|
||||||
while ( true ) {
|
while ( true ) {
|
||||||
button = rb->button_get(true);
|
button = rb->button_get(true);
|
||||||
|
@ -476,7 +476,7 @@ static void cb_start_viewer(char* filename){
|
||||||
|
|
||||||
/* init board */
|
/* init board */
|
||||||
GNUChess_Initialize();
|
GNUChess_Initialize();
|
||||||
|
|
||||||
/* draw the board */
|
/* draw the board */
|
||||||
cb_drawboard();
|
cb_drawboard();
|
||||||
|
|
||||||
|
@ -494,7 +494,7 @@ static void cb_start_viewer(char* filename){
|
||||||
rb->splash ( HZ*2 , "At the begining of the game" );
|
rb->splash ( HZ*2 , "At the begining of the game" );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
board[locn[curr_ply->row_from][curr_ply->column_from]]
|
board[locn[curr_ply->row_from][curr_ply->column_from]]
|
||||||
= board[locn[curr_ply->row_to][curr_ply->column_to]];
|
= board[locn[curr_ply->row_to][curr_ply->column_to]];
|
||||||
color[locn[curr_ply->row_from][curr_ply->column_from]]
|
color[locn[curr_ply->row_from][curr_ply->column_from]]
|
||||||
= color[locn[curr_ply->row_to][curr_ply->column_to]];
|
= color[locn[curr_ply->row_to][curr_ply->column_to]];
|
||||||
|
@ -601,14 +601,14 @@ static int cb_menu(void)
|
||||||
int selection;
|
int selection;
|
||||||
int result = 0;
|
int result = 0;
|
||||||
bool menu_quit = false;
|
bool menu_quit = false;
|
||||||
|
|
||||||
MENUITEM_STRINGLIST(menu,"Chessbox Menu",NULL,"New Game","Resume Game",
|
MENUITEM_STRINGLIST(menu,"Chessbox Menu",NULL,"New Game","Resume Game",
|
||||||
"Save Game", "Restore Game",
|
"Save Game", "Restore Game",
|
||||||
#ifdef HAVE_PLAYBACK_CONTROL
|
#ifdef HAVE_PLAYBACK_CONTROL
|
||||||
"Playback Control",
|
"Playback Control",
|
||||||
#endif
|
#endif
|
||||||
"Quit");
|
"Quit");
|
||||||
|
|
||||||
while(!menu_quit)
|
while(!menu_quit)
|
||||||
{
|
{
|
||||||
switch(rb->do_menu(&menu, &selection, NULL, false))
|
switch(rb->do_menu(&menu, &selection, NULL, false))
|
||||||
|
@ -654,7 +654,7 @@ static struct cb_command cb_getcommand (void) {
|
||||||
int marked = false , from_marked = false ;
|
int marked = false , from_marked = false ;
|
||||||
short marked_x = 0 , marked_y = 0 ;
|
short marked_x = 0 , marked_y = 0 ;
|
||||||
struct cb_command result = { 0, {0,0,0,0,0}, 0 };
|
struct cb_command result = { 0, {0,0,0,0,0}, 0 };
|
||||||
|
|
||||||
cb_switch ( x , y );
|
cb_switch ( x , y );
|
||||||
/* main loop */
|
/* main loop */
|
||||||
while ( true ) {
|
while ( true ) {
|
||||||
|
@ -815,11 +815,11 @@ static void cb_play_game(void) {
|
||||||
|
|
||||||
/* init PGN history data structures */
|
/* init PGN history data structures */
|
||||||
game = pgn_init_game();
|
game = pgn_init_game();
|
||||||
|
|
||||||
/* restore saved position, if saved */
|
/* restore saved position, if saved */
|
||||||
cb_restoreposition();
|
cb_restoreposition();
|
||||||
/* TODO: save/restore the PGN history of unfinished games */
|
/* TODO: save/restore the PGN history of unfinished games */
|
||||||
|
|
||||||
/* draw the board */
|
/* draw the board */
|
||||||
/* I don't like configscreens, start game inmediatly */
|
/* I don't like configscreens, start game inmediatly */
|
||||||
cb_drawboard();
|
cb_drawboard();
|
||||||
|
@ -937,7 +937,7 @@ static void cb_play_game(void) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cb_saveposition();
|
cb_saveposition();
|
||||||
/* TODO: save/restore the PGN history of unfinished games */
|
/* TODO: save/restore the PGN history of unfinished games */
|
||||||
rb->lcd_setfont(FONT_UI);
|
rb->lcd_setfont(FONT_UI);
|
||||||
|
@ -948,7 +948,7 @@ static void cb_play_game(void) {
|
||||||
* plugin entry point.
|
* plugin entry point.
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
enum plugin_status plugin_start(const void* parameter) {
|
enum plugin_status plugin_start(const void* parameter) {
|
||||||
|
|
||||||
/* plugin init */
|
/* plugin init */
|
||||||
|
|
||||||
#if LCD_DEPTH > 1
|
#if LCD_DEPTH > 1
|
||||||
|
@ -957,7 +957,7 @@ enum plugin_status plugin_start(const void* parameter) {
|
||||||
|
|
||||||
/* end of plugin init */
|
/* end of plugin init */
|
||||||
|
|
||||||
/* if the plugin was invoked as a viewer, parse the file and show the game list
|
/* if the plugin was invoked as a viewer, parse the file and show the game list
|
||||||
* else, start playing a game
|
* else, start playing a game
|
||||||
*/
|
*/
|
||||||
if (parameter != NULL) {
|
if (parameter != NULL) {
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
* \/ \/ \/ \/ \/
|
* \/ \/ \/ \/ \/
|
||||||
* $Id$
|
* $Id$
|
||||||
*
|
*
|
||||||
* Copyright (C) 2007 Mauricio Peccorini
|
* Copyright (C) 2007 Mauricio Peccorini
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
|
@ -417,7 +417,7 @@ static void coords_to_pgn(struct pgn_ply_node* ply){
|
||||||
&& ply->column_to + kn_offs[i][1] >= 0 && ply->column_to + kn_offs[i][1] <= 7
|
&& ply->column_to + kn_offs[i][1] >= 0 && ply->column_to + kn_offs[i][1] <= 7
|
||||||
&& board[locn[ply->row_to + kn_offs[i][0]][ply->column_to + kn_offs[i][1]]] == knight
|
&& board[locn[ply->row_to + kn_offs[i][0]][ply->column_to + kn_offs[i][1]]] == knight
|
||||||
&& color[locn[ply->row_to + kn_offs[i][0]][ply->column_to + kn_offs[i][1]]] == ply->player
|
&& color[locn[ply->row_to + kn_offs[i][0]][ply->column_to + kn_offs[i][1]]] == ply->player
|
||||||
&& (ply->row_to + kn_offs[i][0] != ply->row_from
|
&& (ply->row_to + kn_offs[i][0] != ply->row_from
|
||||||
|| ply->column_to + kn_offs[i][1] != ply->column_from)){
|
|| ply->column_to + kn_offs[i][1] != ply->column_from)){
|
||||||
if (ply->row_to + kn_offs[i][0] != ply->row_from){
|
if (ply->row_to + kn_offs[i][0] != ply->row_from){
|
||||||
unambiguous_position = '1' + ply->row_from;
|
unambiguous_position = '1' + ply->row_from;
|
||||||
|
@ -878,5 +878,5 @@ void pgn_store_game(struct pgn_game_node* game){
|
||||||
/* leave a blank line between the tag section and the game section */
|
/* leave a blank line between the tag section and the game section */
|
||||||
rb->fdprintf(fhandler,"\n\n");
|
rb->fdprintf(fhandler,"\n\n");
|
||||||
|
|
||||||
rb->close(fhandler);
|
rb->close(fhandler);
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
* \/ \/ \/ \/ \/
|
* \/ \/ \/ \/ \/
|
||||||
* $Id$
|
* $Id$
|
||||||
*
|
*
|
||||||
* Copyright (C) 2007 Mauricio Peccorini
|
* Copyright (C) 2007 Mauricio Peccorini
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
|
|
|
@ -128,7 +128,7 @@ short unmap[120]=
|
||||||
40,41,42,43,44,45,46,47,-1,-1,-1,-1,-1,-1,-1,-1,
|
40,41,42,43,44,45,46,47,-1,-1,-1,-1,-1,-1,-1,-1,
|
||||||
48,49,50,51,52,53,54,55,-1,-1,-1,-1,-1,-1,-1,-1,
|
48,49,50,51,52,53,54,55,-1,-1,-1,-1,-1,-1,-1,-1,
|
||||||
56,57,58,59,60,61,62,63};
|
56,57,58,59,60,61,62,63};
|
||||||
short Dcode[120]=
|
short Dcode[120]=
|
||||||
{0,1,1,1,1,1,1,1,0,0,0,0,0,0,0x0E,0x0F,
|
{0,1,1,1,1,1,1,1,0,0,0,0,0,0,0x0E,0x0F,
|
||||||
0x10,0x11,0x12,0,0,0,0,0,0,0,0,0,0,0,0x0F,0x1F,
|
0x10,0x11,0x12,0,0,0,0,0,0,0,0,0,0,0,0x0F,0x1F,
|
||||||
0x10,0x21,0x11,0,0,0,0,0,0,0,0,0,0,0x0F,0,0,
|
0x10,0x21,0x11,0,0,0,0,0,0,0,0,0,0,0x0F,0,0,
|
||||||
|
@ -243,7 +243,7 @@ short PawnAdvance[64]=
|
||||||
12,16,24,32,32,24,16,12,
|
12,16,24,32,32,24,16,12,
|
||||||
12,16,24,32,32,24,16,12,
|
12,16,24,32,32,24,16,12,
|
||||||
0, 0, 0, 0, 0, 0, 0, 0};
|
0, 0, 0, 0, 0, 0, 0, 0};
|
||||||
|
|
||||||
/* ............ prototypes ............ */
|
/* ............ prototypes ............ */
|
||||||
void ScorePosition( short side, short *score );
|
void ScorePosition( short side, short *score );
|
||||||
void ScoreLoneKing( short side, short *score );
|
void ScoreLoneKing( short side, short *score );
|
||||||
|
@ -273,7 +273,7 @@ void PutInTTable ( short side, short score, short depth,
|
||||||
short alpha, short beta, unsigned short mv );
|
short alpha, short beta, unsigned short mv );
|
||||||
void ZeroTTable ( void );
|
void ZeroTTable ( void );
|
||||||
void MoveList ( short side, short ply );
|
void MoveList ( short side, short ply );
|
||||||
|
|
||||||
void GenMoves ( short ply, short sq, short side, short xside );
|
void GenMoves ( short ply, short sq, short side, short xside );
|
||||||
void LinkMove ( short ply, short f, short t, short xside );
|
void LinkMove ( short ply, short f, short t, short xside );
|
||||||
void CaptureList ( short side, short xside, short ply );
|
void CaptureList ( short side, short xside, short ply );
|
||||||
|
@ -294,19 +294,19 @@ void ataks ( short side, short *a );
|
||||||
void algbr ( short f, short t, short flag );
|
void algbr ( short f, short t, short flag );
|
||||||
void ElapsedTime( short iop);
|
void ElapsedTime( short iop);
|
||||||
|
|
||||||
void NewGame(void);
|
void NewGame(void);
|
||||||
|
|
||||||
|
|
||||||
/* ............ POSITIONAL EVALUATION ROUTINES ............ */
|
/* ............ POSITIONAL EVALUATION ROUTINES ............ */
|
||||||
|
|
||||||
|
|
||||||
void ScorePosition(side,score)
|
void ScorePosition(side,score)
|
||||||
short side,*score;
|
short side,*score;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Perform normal static evaluation of board position. A score is
|
Perform normal static evaluation of board position. A score is
|
||||||
generated for each piece and these are summed to get a score for each
|
generated for each piece and these are summed to get a score for each
|
||||||
side.
|
side.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -334,10 +334,10 @@ short pscore[3];
|
||||||
}
|
}
|
||||||
if (hung[side] > 1) pscore[side] += HUNGX;
|
if (hung[side] > 1) pscore[side] += HUNGX;
|
||||||
if (hung[xside] > 1) pscore[xside] += HUNGX;
|
if (hung[xside] > 1) pscore[xside] += HUNGX;
|
||||||
|
|
||||||
*score = mtl[side] - mtl[xside] + pscore[side] - pscore[xside] + 10;
|
*score = mtl[side] - mtl[xside] + pscore[side] - pscore[xside] + 10;
|
||||||
if (dither) *score += rb->rand() % dither;
|
if (dither) *score += rb->rand() % dither;
|
||||||
|
|
||||||
if (*score > 0 && pmtl[side] == 0) {
|
if (*score > 0 && pmtl[side] == 0) {
|
||||||
if (emtl[side] < valueR) {
|
if (emtl[side] < valueR) {
|
||||||
*score = 0;
|
*score = 0;
|
||||||
|
@ -352,7 +352,7 @@ short pscore[3];
|
||||||
if (-*score < valueR) *score /= 2;
|
if (-*score < valueR) *score /= 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mtl[xside] == valueK && emtl[side] > valueB) *score += 200;
|
if (mtl[xside] == valueK && emtl[side] > valueB) *score += 200;
|
||||||
if (mtl[side] == valueK && emtl[xside] > valueB) *score -= 200;
|
if (mtl[side] == valueK && emtl[xside] > valueB) *score -= 200;
|
||||||
}
|
}
|
||||||
|
@ -361,7 +361,7 @@ short pscore[3];
|
||||||
void ScoreLoneKing(side,score)
|
void ScoreLoneKing(side,score)
|
||||||
short side,*score;
|
short side,*score;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Static evaluation when loser has only a king and winner has no pawns
|
Static evaluation when loser has only a king and winner has no pawns
|
||||||
or no pieces.
|
or no pieces.
|
||||||
*/
|
*/
|
||||||
|
@ -373,19 +373,19 @@ register short winner,loser,king1,king2,s,i;
|
||||||
if (mtl[white] > mtl[black]) winner = white; else winner = black;
|
if (mtl[white] > mtl[black]) winner = white; else winner = black;
|
||||||
loser = otherside[winner];
|
loser = otherside[winner];
|
||||||
king1 = PieceList[winner][0]; king2 = PieceList[loser][0];
|
king1 = PieceList[winner][0]; king2 = PieceList[loser][0];
|
||||||
|
|
||||||
s = 0;
|
s = 0;
|
||||||
|
|
||||||
if (pmtl[winner] > 0)
|
if (pmtl[winner] > 0)
|
||||||
for (i = 1; i <= PieceCnt[winner]; i++)
|
for (i = 1; i <= PieceCnt[winner]; i++)
|
||||||
s += ScoreKPK(side,winner,loser,king1,king2,PieceList[winner][i]);
|
s += ScoreKPK(side,winner,loser,king1,king2,PieceList[winner][i]);
|
||||||
|
|
||||||
else if (emtl[winner] == valueB+valueN)
|
else if (emtl[winner] == valueB+valueN)
|
||||||
s = ScoreKBNK(winner,king1,king2);
|
s = ScoreKBNK(winner,king1,king2);
|
||||||
|
|
||||||
else if (emtl[winner] > valueB)
|
else if (emtl[winner] > valueB)
|
||||||
s = 500 + emtl[winner] - 2*KingEnding[king2] - 2*distance(king1,king2);
|
s = 500 + emtl[winner] - 2*KingEnding[king2] - 2*distance(king1,king2);
|
||||||
|
|
||||||
if (side == winner) *score = s; else *score = -s;
|
if (side == winner) *score = s; else *score = -s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -399,7 +399,7 @@ short side,winner,loser,king1,king2,sq;
|
||||||
|
|
||||||
{
|
{
|
||||||
register short s,r;
|
register short s,r;
|
||||||
|
|
||||||
if (PieceCnt[winner] == 1) s = 50; else s = 120;
|
if (PieceCnt[winner] == 1) s = 50; else s = 120;
|
||||||
if (winner == white)
|
if (winner == white)
|
||||||
{
|
{
|
||||||
|
@ -569,8 +569,8 @@ short s,piece,in_square,r,mob,e,c;
|
||||||
if (PC2[7] == 0) s += KHOPNX;
|
if (PC2[7] == 0) s += KHOPNX;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (a2 > 0)
|
if (a2 > 0)
|
||||||
{
|
{
|
||||||
c = (control[piece] & 0x4FFF);
|
c = (control[piece] & 0x4FFF);
|
||||||
if (a1 == 0 || a2 > c+1)
|
if (a1 == 0 || a2 > c+1)
|
||||||
|
@ -665,13 +665,13 @@ void BRscan(sq,s,mob)
|
||||||
short sq,*s,*mob;
|
short sq,*s,*mob;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Find Bishop and Rook mobility, XRAY attacks, and pins. Increment the
|
Find Bishop and Rook mobility, XRAY attacks, and pins. Increment the
|
||||||
hung[] array if a pin is found.
|
hung[] array if a pin is found.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
{
|
{
|
||||||
register short m,u,d,m0,j,piece,pin;
|
register short m,u,d,m0,j,piece,pin;
|
||||||
short *Kf;
|
short *Kf;
|
||||||
|
|
||||||
Kf = Kfield[c1];
|
Kf = Kfield[c1];
|
||||||
*mob = 0;
|
*mob = 0;
|
||||||
|
@ -763,9 +763,9 @@ register short u,m,d,i,m0;
|
||||||
void ExaminePosition()
|
void ExaminePosition()
|
||||||
|
|
||||||
/*
|
/*
|
||||||
This is done one time before the search is started. Set up arrays
|
This is done one time before the search is started. Set up arrays
|
||||||
Mwpawn, Mbpawn, Mknight, Mbishop, Mking which are used in the
|
Mwpawn, Mbpawn, Mknight, Mbishop, Mking which are used in the
|
||||||
SqValue() function to determine the positional value of each piece.
|
SqValue() function to determine the positional value of each piece.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -800,14 +800,14 @@ short wpadv,bpadv,wstrong,bstrong,z,side,pp,j,val,Pd,fyle,rank;
|
||||||
if (!PawnStorm && stage < 5)
|
if (!PawnStorm && stage < 5)
|
||||||
PawnStorm = ((column[wking] < 3 && column[bking] > 4) ||
|
PawnStorm = ((column[wking] < 3 && column[bking] > 4) ||
|
||||||
(column[wking] > 4 && column[bking] < 3));
|
(column[wking] > 4 && column[bking] < 3));
|
||||||
|
|
||||||
CopyBoard(pknight,Mknight[white]);
|
CopyBoard(pknight,Mknight[white]);
|
||||||
CopyBoard(pknight,Mknight[black]);
|
CopyBoard(pknight,Mknight[black]);
|
||||||
CopyBoard(pbishop,Mbishop[white]);
|
CopyBoard(pbishop,Mbishop[white]);
|
||||||
CopyBoard(pbishop,Mbishop[black]);
|
CopyBoard(pbishop,Mbishop[black]);
|
||||||
BlendBoard(KingOpening,KingEnding,Mking[white]);
|
BlendBoard(KingOpening,KingEnding,Mking[white]);
|
||||||
BlendBoard(KingOpening,KingEnding,Mking[black]);
|
BlendBoard(KingOpening,KingEnding,Mking[black]);
|
||||||
|
|
||||||
for (sq = 0; sq < 64; sq++)
|
for (sq = 0; sq < 64; sq++)
|
||||||
{
|
{
|
||||||
fyle = column[sq]; rank = row[sq];
|
fyle = column[sq]; rank = row[sq];
|
||||||
|
@ -845,7 +845,7 @@ short wpadv,bpadv,wstrong,bstrong,z,side,pp,j,val,Pd,fyle,rank;
|
||||||
if ((column[bking] < 4 && fyle > 4) ||
|
if ((column[bking] < 4 && fyle > 4) ||
|
||||||
(column[bking] > 3 && fyle < 3)) Mbpawn[sq] -= 3*rank;
|
(column[bking] > 3 && fyle < 3)) Mbpawn[sq] -= 3*rank;
|
||||||
}
|
}
|
||||||
|
|
||||||
Mknight[white][sq] += 5 - distance(sq,bking);
|
Mknight[white][sq] += 5 - distance(sq,bking);
|
||||||
Mknight[white][sq] += 5 - distance(sq,wking);
|
Mknight[white][sq] += 5 - distance(sq,wking);
|
||||||
Mknight[black][sq] += 5 - distance(sq,wking);
|
Mknight[black][sq] += 5 - distance(sq,wking);
|
||||||
|
@ -862,24 +862,24 @@ short wpadv,bpadv,wstrong,bstrong,z,side,pp,j,val,Pd,fyle,rank;
|
||||||
if (bstrong) Mknight[black][sq] += KNIGHTSTRONG;
|
if (bstrong) Mknight[black][sq] += KNIGHTSTRONG;
|
||||||
if (wstrong) Mbishop[white][sq] += BISHOPSTRONG;
|
if (wstrong) Mbishop[white][sq] += BISHOPSTRONG;
|
||||||
if (bstrong) Mbishop[black][sq] += BISHOPSTRONG;
|
if (bstrong) Mbishop[black][sq] += BISHOPSTRONG;
|
||||||
|
|
||||||
if (HasBishop[white] == 2) Mbishop[white][sq] += 8;
|
if (HasBishop[white] == 2) Mbishop[white][sq] += 8;
|
||||||
if (HasBishop[black] == 2) Mbishop[black][sq] += 8;
|
if (HasBishop[black] == 2) Mbishop[black][sq] += 8;
|
||||||
if (HasKnight[white] == 2) Mknight[white][sq] += 5;
|
if (HasKnight[white] == 2) Mknight[white][sq] += 5;
|
||||||
if (HasKnight[black] == 2) Mknight[black][sq] += 5;
|
if (HasKnight[black] == 2) Mknight[black][sq] += 5;
|
||||||
|
|
||||||
if (board[sq] == bishop) {
|
if (board[sq] == bishop) {
|
||||||
if (rank % 2 == fyle % 2) {
|
if (rank % 2 == fyle % 2) {
|
||||||
KBNKsq = 0;
|
KBNKsq = 0;
|
||||||
} else {
|
} else {
|
||||||
KBNKsq = 7;
|
KBNKsq = 7;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Kfield[white][sq] = Kfield[black][sq] = 0;
|
Kfield[white][sq] = Kfield[black][sq] = 0;
|
||||||
if (distance(sq,wking) == 1) Kfield[black][sq] = KATAK;
|
if (distance(sq,wking) == 1) Kfield[black][sq] = KATAK;
|
||||||
if (distance(sq,bking) == 1) Kfield[white][sq] = KATAK;
|
if (distance(sq,bking) == 1) Kfield[white][sq] = KATAK;
|
||||||
|
|
||||||
Pd = 0;
|
Pd = 0;
|
||||||
for (i = 0; i < 64; i++)
|
for (i = 0; i < 64; i++)
|
||||||
if (board[i] == pawn)
|
if (board[i] == pawn)
|
||||||
|
@ -912,9 +912,9 @@ short wpadv,bpadv,wstrong,bstrong,z,side,pp,j,val,Pd,fyle,rank;
|
||||||
|
|
||||||
void UpdateWeights()
|
void UpdateWeights()
|
||||||
|
|
||||||
/*
|
/*
|
||||||
If material balance has changed, determine the values for the
|
If material balance has changed, determine the values for the
|
||||||
positional evaluation terms.
|
positional evaluation terms.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -932,7 +932,7 @@ register short tmtl;
|
||||||
if (tmtl > 3600) stage2 = 0;
|
if (tmtl > 3600) stage2 = 0;
|
||||||
else if (tmtl < 1400) stage2 = 10;
|
else if (tmtl < 1400) stage2 = 10;
|
||||||
else stage2 = (3600-tmtl) / 220;
|
else stage2 = (3600-tmtl) / 220;
|
||||||
|
|
||||||
PEDRNK2B = -15; /* centre pawn on 2nd rank & blocked */
|
PEDRNK2B = -15; /* centre pawn on 2nd rank & blocked */
|
||||||
PBLOK = -4; /* blocked backward pawn */
|
PBLOK = -4; /* blocked backward pawn */
|
||||||
PDOUBLED = -14; /* doubled pawn */
|
PDOUBLED = -14; /* doubled pawn */
|
||||||
|
@ -941,27 +941,27 @@ register short tmtl;
|
||||||
PADVNCM = 10; /* advanced pawn multiplier */
|
PADVNCM = 10; /* advanced pawn multiplier */
|
||||||
PADVNCI = 7; /* muliplier for isolated pawn */
|
PADVNCI = 7; /* muliplier for isolated pawn */
|
||||||
PawnBonus = stage;
|
PawnBonus = stage;
|
||||||
|
|
||||||
KNIGHTPOST = (stage+2)/3; /* knight near enemy pieces */
|
KNIGHTPOST = (stage+2)/3; /* knight near enemy pieces */
|
||||||
KNIGHTSTRONG = (stage+6)/2; /* occupies pawn hole */
|
KNIGHTSTRONG = (stage+6)/2; /* occupies pawn hole */
|
||||||
|
|
||||||
BISHOPSTRONG = (stage+6)/2; /* occupies pawn hole */
|
BISHOPSTRONG = (stage+6)/2; /* occupies pawn hole */
|
||||||
BishopBonus = 2*stage;
|
BishopBonus = 2*stage;
|
||||||
|
|
||||||
RHOPN = 10; /* rook on half open file */
|
RHOPN = 10; /* rook on half open file */
|
||||||
RHOPNX = 4;
|
RHOPNX = 4;
|
||||||
RookBonus = 6*stage;
|
RookBonus = 6*stage;
|
||||||
|
|
||||||
XRAY = 8; /* Xray attack on piece */
|
XRAY = 8; /* Xray attack on piece */
|
||||||
PINVAL = 10; /* Pin */
|
PINVAL = 10; /* Pin */
|
||||||
|
|
||||||
KHOPN = (3*stage-30) / 2; /* king on half open file */
|
KHOPN = (3*stage-30) / 2; /* king on half open file */
|
||||||
KHOPNX = KHOPN / 2;
|
KHOPNX = KHOPN / 2;
|
||||||
KCASTLD = 10 - stage;
|
KCASTLD = 10 - stage;
|
||||||
KMOVD = -40 / (stage+1); /* king moved before castling */
|
KMOVD = -40 / (stage+1); /* king moved before castling */
|
||||||
KATAK = (10-stage) / 2; /* B,R attacks near enemy king */
|
KATAK = (10-stage) / 2; /* B,R attacks near enemy king */
|
||||||
if (stage < 8) KSFTY = 16-2*stage; else KSFTY = 0;
|
if (stage < 8) KSFTY = 16-2*stage; else KSFTY = 0;
|
||||||
|
|
||||||
ATAKD = -6; /* defender > attacker */
|
ATAKD = -6; /* defender > attacker */
|
||||||
HUNGP = -8; /* each hung piece */
|
HUNGP = -8; /* each hung piece */
|
||||||
HUNGX = -12; /* extra for >1 hung piece */
|
HUNGX = -12; /* extra for >1 hung piece */
|
||||||
|
@ -1003,12 +1003,12 @@ register int sq;
|
||||||
int SelectMove( short side, short iop , void (*callback)(void), char* move_buffer)
|
int SelectMove( short side, short iop , void (*callback)(void), char* move_buffer)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Select a move by calling function search() at progressively deeper
|
Select a move by calling function search() at progressively deeper
|
||||||
ply until time is up or a mate or draw is reached. An alpha-beta
|
ply until time is up or a mate or draw is reached. An alpha-beta
|
||||||
window of -90 to +90 points is set around the score returned from the
|
window of -90 to +90 points is set around the score returned from the
|
||||||
previous iteration. If Sdepth != 0 then the program has correctly
|
previous iteration. If Sdepth != 0 then the program has correctly
|
||||||
predicted the opponents move and the search will start at a depth of
|
predicted the opponents move and the search will start at a depth of
|
||||||
Sdepth+1 rather than a depth of 1.
|
Sdepth+1 rather than a depth of 1.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -1032,7 +1032,7 @@ static short i,alpha,beta,score,tempb,tempc,tempsf,tempst,xside,rpt;
|
||||||
ExaminePosition();
|
ExaminePosition();
|
||||||
ScorePosition(side,&score);
|
ScorePosition(side,&score);
|
||||||
Pscore[0] = -score;
|
Pscore[0] = -score;
|
||||||
|
|
||||||
if (Sdepth == 0)
|
if (Sdepth == 0)
|
||||||
{
|
{
|
||||||
ZeroTTable();
|
ZeroTTable();
|
||||||
|
@ -1043,7 +1043,7 @@ static short i,alpha,beta,score,tempb,tempc,tempsf,tempst,xside,rpt;
|
||||||
if (iop != 2) hint = 0;
|
if (iop != 2) hint = 0;
|
||||||
for (i = 0; i < maxdepth; i++)
|
for (i = 0; i < maxdepth; i++)
|
||||||
PrVar[i] = killr0[i] = killr1[i] = killr2[i] = killr3[i] = 0;
|
PrVar[i] = killr0[i] = killr1[i] = killr2[i] = killr3[i] = 0;
|
||||||
|
|
||||||
alpha = -9000; beta = 9000;
|
alpha = -9000; beta = 9000;
|
||||||
rpt = 0;
|
rpt = 0;
|
||||||
TrPnt[1] = 0; root = &Tree[0];
|
TrPnt[1] = 0; root = &Tree[0];
|
||||||
|
@ -1054,7 +1054,7 @@ static short i,alpha,beta,score,tempb,tempc,tempsf,tempst,xside,rpt;
|
||||||
NodeCnt = ETnodes = EvalNodes = HashCnt = 0;
|
NodeCnt = ETnodes = EvalNodes = HashCnt = 0;
|
||||||
Zscore = 0; zwndw = 20;
|
Zscore = 0; zwndw = 20;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (!timeout && Sdepth < MaxSearchDepth)
|
while (!timeout && Sdepth < MaxSearchDepth)
|
||||||
{
|
{
|
||||||
Sdepth++;
|
Sdepth++;
|
||||||
|
@ -1120,7 +1120,7 @@ static short i,alpha,beta,score,tempb,tempc,tempsf,tempst,xside,rpt;
|
||||||
if (score == -9999 || score == 9998) mate = true;
|
if (score == -9999 || score == 9998) mate = true;
|
||||||
if (mate) hint = 0;
|
if (mate) hint = 0;
|
||||||
if (root->flags & cstlmask) Game50 = GameCnt;
|
if (root->flags & cstlmask) Game50 = GameCnt;
|
||||||
else if (board[root->t] == pawn || (root->flags & capture))
|
else if (board[root->t] == pawn || (root->flags & capture))
|
||||||
Game50 = GameCnt;
|
Game50 = GameCnt;
|
||||||
GameList[GameCnt].score = score;
|
GameList[GameCnt].score = score;
|
||||||
GameList[GameCnt].nodes = NodeCnt;
|
GameList[GameCnt].nodes = NodeCnt;
|
||||||
|
@ -1142,13 +1142,13 @@ static short i,alpha,beta,score,tempb,tempc,tempsf,tempst,xside,rpt;
|
||||||
void OpeningBook()
|
void OpeningBook()
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Go thru each of the opening lines of play and check for a match with
|
Go thru each of the opening lines of play and check for a match with
|
||||||
the current game listing. If a match occurs, generate a random number.
|
the current game listing. If a match occurs, generate a random number.
|
||||||
If this number is the largest generated so far then the next move in
|
If this number is the largest generated so far then the next move in
|
||||||
this line becomes the current "candidate". After all lines are
|
this line becomes the current "candidate". After all lines are
|
||||||
checked, the candidate move is put at the top of the Tree[] array and
|
checked, the candidate move is put at the top of the Tree[] array and
|
||||||
will be played by the program. Note that the program does not handle
|
will be played by the program. Note that the program does not handle
|
||||||
book transpositions.
|
book transpositions.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -1203,12 +1203,12 @@ int search( short side, short ply, short depth,
|
||||||
void (*callback)(void) )
|
void (*callback)(void) )
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Perform an alpha-beta search to determine the score for the current
|
Perform an alpha-beta search to determine the score for the current
|
||||||
board position. If depth <= 0 only capturing moves, pawn promotions
|
board position. If depth <= 0 only capturing moves, pawn promotions
|
||||||
and responses to check are generated and searched, otherwise all
|
and responses to check are generated and searched, otherwise all
|
||||||
moves are processed. The search depth is modified for check evasions,
|
moves are processed. The search depth is modified for check evasions,
|
||||||
certain re-captures and threats. Extensions may continue for up to 11
|
certain re-captures and threats. Extensions may continue for up to 11
|
||||||
ply beyond the nominal search depth.
|
ply beyond the nominal search depth.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define prune (cf && score+node->score < alpha)
|
#define prune (cf && score+node->score < alpha)
|
||||||
|
@ -1234,13 +1234,13 @@ struct leaf *node,tmp;
|
||||||
|
|
||||||
NodeCnt++;
|
NodeCnt++;
|
||||||
xside = otherside[side];
|
xside = otherside[side];
|
||||||
|
|
||||||
if (ply <= Sdepth+3) repetition(rpt); else *rpt = 0;
|
if (ply <= Sdepth+3) repetition(rpt); else *rpt = 0;
|
||||||
if (*rpt >= 2) return(0);
|
if (*rpt >= 2) return(0);
|
||||||
|
|
||||||
score = evaluate(side,xside,ply,depth,alpha,beta);
|
score = evaluate(side,xside,ply,depth,alpha,beta);
|
||||||
if (score > 9000) return(score);
|
if (score > 9000) return(score);
|
||||||
|
|
||||||
if (depth > 0)
|
if (depth > 0)
|
||||||
{
|
{
|
||||||
if (InChk || PawnThreat[ply-1] || ReCapture) ++depth;
|
if (InChk || PawnThreat[ply-1] || ReCapture) ++depth;
|
||||||
|
@ -1251,7 +1251,7 @@ struct leaf *node,tmp;
|
||||||
(InChk || PawnThreat[ply-1] || Parry)) depth = 1;
|
(InChk || PawnThreat[ply-1] || Parry)) depth = 1;
|
||||||
else if (score <= beta && MateThreat) depth = 1;
|
else if (score <= beta && MateThreat) depth = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
PV = 0;
|
PV = 0;
|
||||||
if (depth > 0 && hashflag && ply > 1)
|
if (depth > 0 && hashflag && ply > 1)
|
||||||
{
|
{
|
||||||
|
@ -1261,7 +1261,7 @@ struct leaf *node,tmp;
|
||||||
if (beta == -20000) return(score);
|
if (beta == -20000) return(score);
|
||||||
if (alpha > beta) return(alpha);
|
if (alpha > beta) return(alpha);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Sdepth == 1) d = 7; else d = 11;
|
if (Sdepth == 1) d = 7; else d = 11;
|
||||||
if (ply > Sdepth+d || (depth <= 0 && score > beta)) return(score);
|
if (ply > Sdepth+d || (depth <= 0 && score > beta)) return(score);
|
||||||
|
|
||||||
|
@ -1272,14 +1272,14 @@ struct leaf *node,tmp;
|
||||||
CaptureList(side,xside,ply);
|
CaptureList(side,xside,ply);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TrPnt[ply] == TrPnt[ply+1]) return(score);
|
if (TrPnt[ply] == TrPnt[ply+1]) return(score);
|
||||||
|
|
||||||
cf = (depth < 1 && ply > Sdepth+1 && !ChkFlag[ply-2] && !slk);
|
cf = (depth < 1 && ply > Sdepth+1 && !ChkFlag[ply-2] && !slk);
|
||||||
|
|
||||||
if (depth > 0) best = -12000; else best = score;
|
if (depth > 0) best = -12000; else best = score;
|
||||||
if (best > alpha) alpha = best;
|
if (best > alpha) alpha = best;
|
||||||
|
|
||||||
for (pnt = pbst = TrPnt[ply];
|
for (pnt = pbst = TrPnt[ply];
|
||||||
pnt < TrPnt[ply+1] && best <= beta;
|
pnt < TrPnt[ply+1] && best <= beta;
|
||||||
pnt++)
|
pnt++)
|
||||||
|
@ -1288,7 +1288,7 @@ struct leaf *node,tmp;
|
||||||
node = &Tree[pnt];
|
node = &Tree[pnt];
|
||||||
mv = (node->f << 8) + node->t;
|
mv = (node->f << 8) + node->t;
|
||||||
nxtline[ply+1] = 0;
|
nxtline[ply+1] = 0;
|
||||||
|
|
||||||
if (prune) break;
|
if (prune) break;
|
||||||
if (ply == 1) UpdateSearchStatus;
|
if (ply == 1) UpdateSearchStatus;
|
||||||
|
|
||||||
|
@ -1339,7 +1339,7 @@ struct leaf *node,tmp;
|
||||||
if (NodeCnt > ETnodes) ElapsedTime(0);
|
if (NodeCnt > ETnodes) ElapsedTime(0);
|
||||||
if (timeout) return(-Tscore[ply-1]);
|
if (timeout) return(-Tscore[ply-1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
node = &Tree[pbst];
|
node = &Tree[pbst];
|
||||||
mv = (node->f<<8) + node->t;
|
mv = (node->f<<8) + node->t;
|
||||||
if (hashflag && ply <= Sdepth && *rpt == 0 && best == alpha)
|
if (hashflag && ply <= Sdepth && *rpt == 0 && best == alpha)
|
||||||
|
@ -1368,13 +1368,13 @@ int evaluate(side,xside,ply,depth,alpha,beta)
|
||||||
short side,xside,ply,depth,alpha,beta;
|
short side,xside,ply,depth,alpha,beta;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Compute an estimate of the score by adding the positional score from
|
Compute an estimate of the score by adding the positional score from
|
||||||
the previous ply to the material difference. If this score falls
|
the previous ply to the material difference. If this score falls
|
||||||
inside a window which is 180 points wider than the alpha-beta window
|
inside a window which is 180 points wider than the alpha-beta window
|
||||||
(or within a 50 point window during quiescence search) call
|
(or within a 50 point window during quiescence search) call
|
||||||
ScorePosition() to determine a score, otherwise return the estimated
|
ScorePosition() to determine a score, otherwise return the estimated
|
||||||
score. If one side has only a king and the other either has no pawns
|
score. If one side has only a king and the other either has no pawns
|
||||||
or no pieces then the function ScoreLoneKing() is called.
|
or no pieces then the function ScoreLoneKing() is called.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -1384,13 +1384,13 @@ register short evflag;
|
||||||
hung[white] = hung[black] = 0;
|
hung[white] = hung[black] = 0;
|
||||||
slk = ((mtl[white] == valueK && (pmtl[black] == 0 || emtl[black] == 0)) ||
|
slk = ((mtl[white] == valueK && (pmtl[black] == 0 || emtl[black] == 0)) ||
|
||||||
(mtl[black] == valueK && (pmtl[white] == 0 || emtl[white] == 0)));
|
(mtl[black] == valueK && (pmtl[white] == 0 || emtl[white] == 0)));
|
||||||
|
|
||||||
if (slk) evflag = false;
|
if (slk) evflag = false;
|
||||||
else evflag =
|
else evflag =
|
||||||
(ply == 1 || ply < Sdepth ||
|
(ply == 1 || ply < Sdepth ||
|
||||||
(depth == 0 && Xscore > alpha-xwndw && Xscore < beta+xwndw) ||
|
(depth == 0 && Xscore > alpha-xwndw && Xscore < beta+xwndw) ||
|
||||||
(depth < 0 && Xscore > alpha-25 && Xscore < beta+25));
|
(depth < 0 && Xscore > alpha-25 && Xscore < beta+25));
|
||||||
|
|
||||||
if (evflag)
|
if (evflag)
|
||||||
{
|
{
|
||||||
EvalNodes++;
|
EvalNodes++;
|
||||||
|
@ -1406,7 +1406,7 @@ register short evflag;
|
||||||
InChk = SqAtakd(PieceList[side][0],xside);
|
InChk = SqAtakd(PieceList[side][0],xside);
|
||||||
if (slk) ScoreLoneKing(side,&Xscore);
|
if (slk) ScoreLoneKing(side,&Xscore);
|
||||||
}
|
}
|
||||||
|
|
||||||
Pscore[ply] = Xscore - mtl[side] + mtl[xside];
|
Pscore[ply] = Xscore - mtl[side] + mtl[xside];
|
||||||
if (InChk) ChkFlag[ply-1] = Pindex[TOsquare];
|
if (InChk) ChkFlag[ply-1] = Pindex[TOsquare];
|
||||||
else ChkFlag[ply-1] = 0;
|
else ChkFlag[ply-1] = 0;
|
||||||
|
@ -1417,7 +1417,7 @@ register short evflag;
|
||||||
int ProbeTTable(side,depth,alpha,beta,score)
|
int ProbeTTable(side,depth,alpha,beta,score)
|
||||||
short side,depth,*alpha,*beta,*score;
|
short side,depth,*alpha,*beta,*score;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Look for the current board position in the transposition table.
|
Look for the current board position in the transposition table.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -1466,7 +1466,7 @@ short hindx;
|
||||||
ptbl = (ttable + hindx);
|
ptbl = (ttable + hindx);
|
||||||
ptbl->hashbd = hashbd;
|
ptbl->hashbd = hashbd;
|
||||||
ptbl->depth = depth;
|
ptbl->depth = depth;
|
||||||
ptbl->score = score;
|
ptbl->score = score;
|
||||||
ptbl->mv = mv;
|
ptbl->mv = mv;
|
||||||
ptbl->flags = 0;
|
ptbl->flags = 0;
|
||||||
if (score < alpha) ptbl->flags |= upperbound;
|
if (score < alpha) ptbl->flags |= upperbound;
|
||||||
|
@ -1491,10 +1491,10 @@ void MoveList(side,ply)
|
||||||
short side,ply;
|
short side,ply;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Fill the array Tree[] with all available moves for side to play. Array
|
Fill the array Tree[] with all available moves for side to play. Array
|
||||||
TrPnt[ply] contains the index into Tree[] of the first move at a ply.
|
TrPnt[ply] contains the index into Tree[] of the first move at a ply.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
{
|
{
|
||||||
register short i,xside,f;
|
register short i,xside,f;
|
||||||
|
|
||||||
|
@ -1528,15 +1528,15 @@ void GenMoves(ply,sq,side,xside)
|
||||||
short ply,sq,side,xside;
|
short ply,sq,side,xside;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Generate moves for a piece. The from square is mapped onto a special
|
Generate moves for a piece. The from square is mapped onto a special
|
||||||
board and offsets (taken from array Dir[]) are added to the mapped
|
board and offsets (taken from array Dir[]) are added to the mapped
|
||||||
location. The newly generated square is tested to see if it falls off
|
location. The newly generated square is tested to see if it falls off
|
||||||
the board by ANDing the square with 88 HEX. Legal moves are linked
|
the board by ANDing the square with 88 HEX. Legal moves are linked
|
||||||
into the tree.
|
into the tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
{
|
{
|
||||||
register short m,u,d,i,m0,piece;
|
register short m,u,d,i,m0,piece;
|
||||||
|
|
||||||
piece = board[sq]; m0 = map[sq];
|
piece = board[sq]; m0 = map[sq];
|
||||||
if (sweep[piece])
|
if (sweep[piece])
|
||||||
|
@ -1605,7 +1605,7 @@ short ply,f,t,xside;
|
||||||
2. Capture of last moved piece
|
2. Capture of last moved piece
|
||||||
3. Other captures (major pieces first)
|
3. Other captures (major pieces first)
|
||||||
4. Killer moves
|
4. Killer moves
|
||||||
5. "history" killers
|
5. "history" killers
|
||||||
*/
|
*/
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -1688,7 +1688,7 @@ struct leaf *node;
|
||||||
}
|
}
|
||||||
PL = PieceList[side];
|
PL = PieceList[side];
|
||||||
for (i = 0; i <= PieceCnt[side]; i++)
|
for (i = 0; i <= PieceCnt[side]; i++)
|
||||||
{
|
{
|
||||||
sq = PL[i];
|
sq = PL[i];
|
||||||
m0 = map[sq]; piece = board[sq];
|
m0 = map[sq]; piece = board[sq];
|
||||||
j1 = Dstart[piece]; j2 = Dstop[piece];
|
j1 = Dstart[piece]; j2 = Dstop[piece];
|
||||||
|
@ -1724,7 +1724,7 @@ struct leaf *node;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int castle(side,kf,kt,iop)
|
int castle(side,kf,kt,iop)
|
||||||
short side,kf,kt,iop;
|
short side,kf,kt,iop;
|
||||||
|
|
||||||
|
@ -1792,7 +1792,7 @@ register short l;
|
||||||
{
|
{
|
||||||
board[l] = no_piece; color[l] = neutral;
|
board[l] = no_piece; color[l] = neutral;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
board[l] = pawn; color[l] = xside;
|
board[l] = pawn; color[l] = xside;
|
||||||
}
|
}
|
||||||
|
@ -1805,11 +1805,11 @@ short side,*tempc,*tempb,*tempsf,*tempst;
|
||||||
struct leaf *node;
|
struct leaf *node;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Update Arrays board[], color[], and Pindex[] to reflect the new board
|
Update Arrays board[], color[], and Pindex[] to reflect the new board
|
||||||
position obtained after making the move pointed to by node. Also
|
position obtained after making the move pointed to by node. Also
|
||||||
update miscellaneous stuff that changes when a move is made.
|
update miscellaneous stuff that changes when a move is made.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
{
|
{
|
||||||
register short f,t,xside,ct,cf;
|
register short f,t,xside,ct,cf;
|
||||||
|
|
||||||
|
@ -1874,7 +1874,7 @@ register short f,t,xside,ct,cf;
|
||||||
UpdateHashbd(side,queen,f,-1);
|
UpdateHashbd(side,queen,f,-1);
|
||||||
}
|
}
|
||||||
INCscore -= *tempsf;
|
INCscore -= *tempsf;
|
||||||
}
|
}
|
||||||
if (board[t] == king) ++kingmoved[side];
|
if (board[t] == king) ++kingmoved[side];
|
||||||
if (node->flags & epmask) EnPassant(xside,f,t,1);
|
if (node->flags & epmask) EnPassant(xside,f,t,1);
|
||||||
else if (hashflag) UpdateHashbd(side,board[t],f,t);
|
else if (hashflag) UpdateHashbd(side,board[t],f,t);
|
||||||
|
@ -1913,7 +1913,7 @@ register short f,t,xside;
|
||||||
UpdateHashbd(side,queen,-1,t);
|
UpdateHashbd(side,queen,-1,t);
|
||||||
UpdateHashbd(side,pawn,-1,t);
|
UpdateHashbd(side,pawn,-1,t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (*tempc != neutral)
|
if (*tempc != neutral)
|
||||||
{
|
{
|
||||||
UpdatePieceList(*tempc,t,2);
|
UpdatePieceList(*tempc,t,2);
|
||||||
|
@ -1938,10 +1938,10 @@ void UpdateHashbd(side,piece,f,t)
|
||||||
short side,piece,f,t;
|
short side,piece,f,t;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
hashbd contains a 32 bit "signature" of the board position. hashkey
|
hashbd contains a 32 bit "signature" of the board position. hashkey
|
||||||
contains a 16 bit code used to address the hash table. When a move is
|
contains a 16 bit code used to address the hash table. When a move is
|
||||||
made, XOR'ing the hashcode of moved piece on the from and to squares
|
made, XOR'ing the hashcode of moved piece on the from and to squares
|
||||||
with the hashbd and hashkey values keeps things current.
|
with the hashbd and hashkey values keeps things current.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -1962,8 +1962,8 @@ void UpdatePieceList(side,sq,iop)
|
||||||
short side,sq,iop;
|
short side,sq,iop;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Update the PieceList and Pindex arrays when a piece is captured or
|
Update the PieceList and Pindex arrays when a piece is captured or
|
||||||
when a capture is unmade.
|
when a capture is unmade.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -1989,13 +1989,13 @@ register short i;
|
||||||
void InitializeStats()
|
void InitializeStats()
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Scan thru the board seeing what's on each square. If a piece is found,
|
Scan thru the board seeing what's on each square. If a piece is found,
|
||||||
update the variables PieceCnt, PawnCnt, Pindex and PieceList. Also
|
update the variables PieceCnt, PawnCnt, Pindex and PieceList. Also
|
||||||
determine the material for each side and set the hashkey and hashbd
|
determine the material for each side and set the hashkey and hashbd
|
||||||
variables to represent the current board position. Array
|
variables to represent the current board position. Array
|
||||||
PieceList[side][indx] contains the location of all the pieces of
|
PieceList[side][indx] contains the location of all the pieces of
|
||||||
either side. Array Pindex[sq] contains the indx into PieceList for a
|
either side. Array Pindex[sq] contains the indx into PieceList for a
|
||||||
given square.
|
given square.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -2027,9 +2027,9 @@ register short i,sq;
|
||||||
void pick(p1,p2)
|
void pick(p1,p2)
|
||||||
short p1,p2;
|
short p1,p2;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Find the best move in the tree between indexes p1 and p2. Swap the
|
Find the best move in the tree between indexes p1 and p2. Swap the
|
||||||
best move into the p1 element.
|
best move into the p1 element.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -2081,7 +2081,7 @@ short sq,side;
|
||||||
/*
|
/*
|
||||||
See if any piece with color 'side' ataks sq. First check for pawns
|
See if any piece with color 'side' ataks sq. First check for pawns
|
||||||
or king, then try other pieces. Array Dcode is used to check for
|
or king, then try other pieces. Array Dcode is used to check for
|
||||||
knight attacks or R,B,Q co-linearity.
|
knight attacks or R,B,Q co-linearity.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -2095,7 +2095,7 @@ register short m,d,m0,m1,i,loc,piece,*PL;
|
||||||
if (!(m & 0x88))
|
if (!(m & 0x88))
|
||||||
if (board[unmap[m]] == pawn && color[unmap[m]] == side) return(true);
|
if (board[unmap[m]] == pawn && color[unmap[m]] == side) return(true);
|
||||||
if (distance(sq,PieceList[side][0]) == 1) return(true);
|
if (distance(sq,PieceList[side][0]) == 1) return(true);
|
||||||
|
|
||||||
PL = PieceList[side];
|
PL = PieceList[side];
|
||||||
for (i = 1; i <= PieceCnt[side]; i++)
|
for (i = 1; i <= PieceCnt[side]; i++)
|
||||||
{
|
{
|
||||||
|
@ -2128,8 +2128,8 @@ short side,*a;
|
||||||
{
|
{
|
||||||
register short u,m,d,c,m0;
|
register short u,m,d,c,m0;
|
||||||
short j,j1,j2,piece,i,sq,*PL;
|
short j,j1,j2,piece,i,sq,*PL;
|
||||||
|
|
||||||
for (u = 0; u < 64; a[u++] = 0);
|
for (u = 0; u < 64; a[u++] = 0);
|
||||||
Dstart[pawn] = Dpwn[side]; Dstop[pawn] = Dstart[pawn] + 1;
|
Dstart[pawn] = Dpwn[side]; Dstop[pawn] = Dstart[pawn] + 1;
|
||||||
PL = PieceList[side];
|
PL = PieceList[side];
|
||||||
for (i = 0; i <= PieceCnt[side]; i++)
|
for (i = 0; i <= PieceCnt[side]; i++)
|
||||||
|
@ -2164,10 +2164,10 @@ short j,j1,j2,piece,i,sq,*PL;
|
||||||
|
|
||||||
void ElapsedTime(iop)
|
void ElapsedTime(iop)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Determine the time that has passed since the search was started. If
|
Determine the time that has passed since the search was started. If
|
||||||
the elapsed time exceeds the target (ResponseTime+ExtraTime) then set
|
the elapsed time exceeds the target (ResponseTime+ExtraTime) then set
|
||||||
timeout to true which will terminate the search.
|
timeout to true which will terminate the search.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
short iop;
|
short iop;
|
||||||
|
@ -2230,7 +2230,7 @@ void SetTimeControl( void )
|
||||||
int VerifyMove(short player, char s[],short iop,unsigned short *mv, char *move_buffer)
|
int VerifyMove(short player, char s[],short iop,unsigned short *mv, char *move_buffer)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Compare the string 's' to the list of legal moves available for the
|
Compare the string 's' to the list of legal moves available for the
|
||||||
player. If a match is found, make the move on the board. This was originally
|
player. If a match is found, make the move on the board. This was originally
|
||||||
fixed for the opponent, but allowing the player to be specified will make
|
fixed for the opponent, but allowing the player to be specified will make
|
||||||
possible to use GnuChess as a human vs human game verifier. It also allows
|
possible to use GnuChess as a human vs human game verifier. It also allows
|
||||||
|
@ -2277,7 +2277,7 @@ short opponent_player = (player == white)?black:white;
|
||||||
/*if (xnode.flags & epmask) UpdateDisplay(0,0,1,0);
|
/*if (xnode.flags & epmask) UpdateDisplay(0,0,1,0);
|
||||||
else UpdateDisplay(xnode.f,xnode.t,0,xnode.flags & cstlmask);*/
|
else UpdateDisplay(xnode.f,xnode.t,0,xnode.flags & cstlmask);*/
|
||||||
if (xnode.flags & cstlmask) Game50 = GameCnt;
|
if (xnode.flags & cstlmask) Game50 = GameCnt;
|
||||||
else if (board[xnode.t] == pawn || (xnode.flags & capture))
|
else if (board[xnode.t] == pawn || (xnode.flags & capture))
|
||||||
Game50 = GameCnt;
|
Game50 = GameCnt;
|
||||||
GameList[GameCnt].depth = GameList[GameCnt].score = 0;
|
GameList[GameCnt].depth = GameList[GameCnt].score = 0;
|
||||||
GameList[GameCnt].nodes = 0;
|
GameList[GameCnt].nodes = 0;
|
||||||
|
@ -2298,7 +2298,7 @@ short opponent_player = (player == white)?black:white;
|
||||||
}
|
}
|
||||||
|
|
||||||
return(true);
|
return(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*if (cnt > 1) ShowMessage("Ambiguous Move!");*/
|
/*if (cnt > 1) ShowMessage("Ambiguous Move!");*/
|
||||||
return(false);
|
return(false);
|
||||||
|
@ -2363,7 +2363,7 @@ void GNUChess_Initialize ( void ) {
|
||||||
TCminutes = 5;
|
TCminutes = 5;
|
||||||
TCflag = true;
|
TCflag = true;
|
||||||
NewGame();
|
NewGame();
|
||||||
MaxSearchDepth = 29 ;
|
MaxSearchDepth = 29 ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void algbr(f,t,flag)
|
void algbr(f,t,flag)
|
||||||
|
@ -2381,7 +2381,7 @@ short f,t,flag;
|
||||||
rb->memcpy(mvstr2,"o-o-o", 5);
|
rb->memcpy(mvstr2,"o-o-o", 5);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (board[f] == pawn) mvstr3[0] = mvstr1[0];
|
if (board[f] == pawn) mvstr3[0] = mvstr1[0];
|
||||||
else mvstr3[0] = qxx[board[f]];
|
else mvstr3[0] = qxx[board[f]];
|
||||||
if (color[t] != neutral)
|
if (color[t] != neutral)
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
#define neutral 2
|
#define neutral 2
|
||||||
#define white 0
|
#define white 0
|
||||||
#define black 1
|
#define black 1
|
||||||
#define no_piece 0
|
#define no_piece 0
|
||||||
#define pawn 1
|
#define pawn 1
|
||||||
#define knight 2
|
#define knight 2
|
||||||
|
|
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue