X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=gnushogi%2Fsearch.c;h=1c4bbf7b994ccedac77b212f99074f7beb3fc49f;hb=HEAD;hp=3d49b8b897cdbc32d062bb56431bf7f247a6ca80;hpb=1aca00e04580e7b3effefa535edb469876ecce74;p=gnushogi.git diff --git a/gnushogi/search.c b/gnushogi/search.c index 3d49b8b..1c4bbf7 100644 --- a/gnushogi/search.c +++ b/gnushogi/search.c @@ -4,6 +4,7 @@ * ---------------------------------------------------------------------- * Copyright (c) 1993, 1994, 1995 Matthias Mutz * Copyright (c) 1999 Michael Vanier and the Free Software Foundation + * Copyright (c) 2008, 2013, 2014 Yann Dirson and the Free Software Foundation * * GNU SHOGI is based on GNU CHESS * @@ -14,8 +15,8 @@ * * GNU Shogi 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 1, or (at your option) any - * later version. + * Free Software Foundation; either version 3 of the License, + * or (at your option) any later version. * * GNU Shogi is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or @@ -23,18 +24,14 @@ * for more details. * * You should have received a copy of the GNU General Public License along - * with GNU Shogi; see the file COPYING. If not, write to the Free - * Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * with GNU Shogi; see the file COPYING. If not, see + * . * ---------------------------------------------------------------------- * */ #include "gnushogi.h" -#if !defined OLDTIME && defined HAVE_GETTIMEOFDAY -double pow(double x, double y); -#endif - short background = 0; static short DepthBeyond; unsigned short PrVar[MAXDEPTH]; @@ -176,6 +173,7 @@ SelectMove(short side, SelectMove_mode iop) } else { + background = false; /* [HGM] with ponder on we did not switch back to foreground mode??? */ player = side; SetResponseTime(side); } @@ -183,7 +181,7 @@ SelectMove(short side, SelectMove_mode iop) #ifdef QUIETBACKGROUND if (!background) #endif /* QUIETBACKGROUND */ - ShowResponseTime(); + dsp->ShowResponseTime(); ExtraTime = 0; @@ -192,12 +190,12 @@ SelectMove(short side, SelectMove_mode iop) #ifdef QUIETBACKGROUND if (!background) #endif /* QUIETBACKGROUND */ - ShowSidetoMove(); + dsp->ShowSidetoMove(); #ifdef QUIETBACKGROUND if (!background) #endif /* QUIETBACKGROUND */ - SearchStartStuff(side); + dsp->SearchStartStuff(side); #ifdef HISTORY array_zero(history, sizeof_history); @@ -261,7 +259,7 @@ SelectMove(short side, SelectMove_mode iop) if (flag.regularstart && Book) { - flag.timeout = bookflag = OpeningBook(&hint, side); + flag.timeout = bookflag = OpeningBook(&hint); if (TCflag) ResponseTime += ResponseTime; @@ -307,7 +305,7 @@ SelectMove(short side, SelectMove_mode iop) # ifdef QUIETBACKGROUND if (!background) #endif /* QUIETBACKGROUND */ - ShowDepth(' '); + dsp->ShowDepth(' '); /* search at this level returns score of PV */ score = search(side, 1, Sdepth, alpha, beta, PrVar, &rpt); @@ -323,7 +321,7 @@ SelectMove(short side, SelectMove_mode iop) #ifdef QUIETBACKGROUND if (!background) #endif /* QUIETBACKGROUND */ - ShowDepth('-'); + dsp->ShowDepth('-'); if (TCflag && TCcount < MAXTCCOUNTR) { @@ -345,7 +343,7 @@ SelectMove(short side, SelectMove_mode iop) #ifdef QUIETBACKGROUND if (!background) #endif /* QUIETBACKGROUND */ - ShowDepth('+'); + dsp->ShowDepth('+'); score = search(side, 1, Sdepth, -(SCORE_LIMIT + 999), (SCORE_LIMIT + 999), PrVar, &rpt); @@ -398,7 +396,7 @@ SelectMove(short side, SelectMove_mode iop) #ifdef QUIETBACKGROUND if (!background) #endif /* QUIETBACKGROUND */ - ShowResults(score, PrVar, '.'); + dsp->ShowResults(score, PrVar, '.'); } /********************** end of main loop ***************************/ @@ -410,7 +408,7 @@ SelectMove(short side, SelectMove_mode iop) if (rpt >= 3) { root->flags |= draw; - DRAW = CP[101]; /* Repetition */ + DRAW = DRAW_REPETITION; } else { @@ -422,7 +420,7 @@ SelectMove(short side, SelectMove_mode iop) if (GameCnt == MAXMOVES) { root->flags |= draw; - DRAW = CP[80]; /* Max Moves */ + DRAW = DRAW_MAXMOVES; } } @@ -455,7 +453,7 @@ SelectMove(short side, SelectMove_mode iop) ElapsedTime(COMPUTE_AND_INIT_MODE); /* update time control info */ - OutputMove(); + dsp->OutputMove(); /* if mate set flag */ if ((score == -(SCORE_LIMIT + 999) || score == (SCORE_LIMIT + 998))) @@ -583,7 +581,7 @@ search(short side, #ifdef QUIETBACKGROUND if (!background) #endif - ShowResponseTime(); + dsp->ShowResponseTime(); } else if (!TCflag && flag.musttimeout && Sdepth > MINDEPTH) { @@ -713,7 +711,7 @@ search(short side, && (ProbeFTable(side, depth, ply, &alpha, &beta, &score) == true)) { - PutInTTable(side, score, depth, ply, alpha, beta, PV); + PutInTTable(side, score, depth, ply, beta, PV); bstline[ply] = PV; bstline[ply + 1] = 0; @@ -864,7 +862,6 @@ search(short side, nxtline[ply + 1] = 0; /* if at top level */ -#if !defined NOPOST if (ply == 1) { /* at the top update search status */ @@ -873,10 +870,9 @@ search(short side, #ifdef QUIETBACKGROUND if (!background) #endif /* QUIETBACKGROUND */ - ShowCurrentMove(pnt, node->f, node->t); + dsp->ShowCurrentMove(pnt, node->f, node->t); } } -#endif if (!(node->flags & exact)) { @@ -884,7 +880,7 @@ search(short side, MakeMove(side, node, &tempb, &tempc, &tempsf, &tempst, &INCscore); - CptrFlag[ply] = (node->flags & capture); + CptrFlag[ply] = ((node->flags & capture) != 0); TesujiFlag[ply] = (node->flags & tesuji) && (node->flags & dropmask); Tscore[ply] = node->score; @@ -914,7 +910,7 @@ search(short side, && !ChkFlag[ply]))) { node->flags |= (draw | exact); - DRAW = CP[58]; /* Draw */ + DRAW = DRAW_JUSTDRAW; node->score = ((side == computer) ? contempt : -contempt); } @@ -987,15 +983,15 @@ search(short side, { if (best > beta) { - ShowResults(best, bstline, '+'); + dsp->ShowResults(best, bstline, '+'); } else if (best < alpha) { - ShowResults(best, bstline, '-'); + dsp->ShowResults(best, bstline, '-'); } else { - ShowResults (best, bstline, '&'); + dsp->ShowResults(best, bstline, '&'); } } #ifdef QUIETBACKGROUND @@ -1028,13 +1024,13 @@ search(short side, { # ifdef HASHFILE /* MCV: warning: this confuses the formatter. */ if (use_ttable - && PutInTTable(side, best, depth, ply, alpha, beta, mv) + && PutInTTable(side, best, depth, ply, beta, mv) && hashfile && (depth > HashDepth) && (GameCnt < HashMoveLimit)) # else if (use_ttable - && PutInTTable(side, best, depth, ply, alpha, beta, mv)) + && PutInTTable(side, best, depth, ply, beta, mv)) # endif { PutInFTable(side, best, depth, ply, @@ -1119,8 +1115,8 @@ UpdatePieceList(short side, short sq, UpdatePieceList_mode iop) /* Make or Unmake drop move. */ -void -drop(short side, short piece, short f, short t, short iop) +static void +drop(short side, short piece, short t, short iop) { if (iop == 1) { @@ -1288,7 +1284,7 @@ MakeMove(short side, *tempst = svalue[t]; #endif - (void)drop(side, g->fpiece, f, t, 1); + (void)drop(side, g->fpiece, t, 1); } else { @@ -1416,7 +1412,7 @@ UnmakeMove(short side, if (node->flags & dropmask) { - (void)drop(side, (node->flags & pmask), f, t, 2); + (void)drop(side, (node->flags & pmask), t, 2); #if !defined SAVE_SVALUE svalue[t] = *tempst;