X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=gnushogi%2Feval.c;h=cbae96804230327b20852fc8cf35f0ac769cec54;hb=3abc03f7170b55bfcf97c4009abb570f62e48a24;hp=272db911e18b7a0dbafc796a4435af501f6f12e7;hpb=7c5f6ecf842604527da7c24a7ed873ef04bd616a;p=gnushogi.git diff --git a/gnushogi/eval.c b/gnushogi/eval.c index 272db91..cbae968 100644 --- a/gnushogi/eval.c +++ b/gnushogi/eval.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 * @@ -1354,6 +1355,12 @@ PawnValue(short sq, short side) if (in_opening_stage) { +#ifndef MINISHOGI +/* FIXME: [HGM] The 3rd-rank Pawn section is meaningless in mini-Shogi, + * (which does not have opposing Pawns), and can do out-of-bound access, + * as the promotion zone is only 1 rank, so Pawns can be closer than 3 ranks + * to the board edge. + */ if (crow(c1, sq) == 2) /* pawn on 3d rank */ { if (board[(c1 == black) ? @@ -1383,6 +1390,9 @@ PawnValue(short sq, short side) } } +/* FIXME: calculations below are wrong for minishogi, all done for 9x9 + * board - and anyway we don't know the stage really :) + */ if ((GameType[c1] == STATIC_ROOK) && (sq == csquare(c1, 43))) { if ((atk2[csquare(c1, 52)] & CNT_MASK) < 2) @@ -1404,6 +1414,7 @@ PawnValue(short sq, short side) s += (ds = -2 * fv1[ATTACKED]); } } +#endif } return s; @@ -1497,6 +1508,10 @@ SilverValue(short sq, short side) if (in_opening_stage) { +#ifndef MINISHOGI +/* FIXME: calculations below are wrong for minishogi, all done for 9x9 + * board - and anyway we don't know the stage really :) + */ if (GameType[c1] == STATIC_ROOK) { if (csquare(c1, sq) == 12) @@ -1510,6 +1525,7 @@ SilverValue(short sq, short side) } } } +#endif } else { @@ -1540,6 +1556,10 @@ GoldValue(short sq, short side) if (in_opening_stage) { +#ifndef MINISHOGI +/* FIXME: calculations below are wrong for minishogi, all done for 9x9 + * board - and anyway we don't know the stage really :) + */ if ((GameType[c1] == STATIC_ROOK) && (GameType[c2] != STATIC_ROOK)) { if (Mvboard[csquare(c1, 3)]) @@ -1547,6 +1567,7 @@ GoldValue(short sq, short side) s += (ds = -2 * fv1[OPENWRONG]); } } +#endif } else { @@ -1569,6 +1590,10 @@ BishopValue(short sq, short side) if (in_opening_stage) { +#ifndef MINISHOGI +/* FIXME: calculations below are wrong for minishogi, all done for 9x9 + * board - and anyway we don't know the stage really :) + */ if (GameType[c1] == RANGING_ROOK) { /* Bishops diagonal should not be open */ @@ -1590,6 +1615,7 @@ BishopValue(short sq, short side) s += (ds = -fv1[OPENWRONG]); } } +#endif } else { @@ -1614,6 +1640,10 @@ RookValue(short sq, short side) if (in_opening_stage) { +#ifndef MINISHOGI +/* FIXME: calculations below are wrong for minishogi, all done for 9x9 + * board - and anyway we don't know the stage really :) + */ short WRONG = fv1[OPENWRONG], OPOK = WRONG / 3; if (GameType[c1] == STATIC_ROOK) @@ -1672,6 +1702,7 @@ RookValue(short sq, short side) } } } +#endif } else { @@ -1795,6 +1826,10 @@ KingValue(short sq, short side) if (fv1[KSFTY] != 0) s += KingScan(sq); +#ifndef MINISHOGI +/* FIXME: calculations below are wrong for minishogi, all done for 9x9 + * board - and anyway we don't know the stage really :) + */ if (in_opening_stage) { if ((GameType[c1] != UNKNOWN) && (ccolumn(c1, sq) == 4)) @@ -1810,6 +1845,7 @@ KingValue(short sq, short side) s += (ds = -fv1[OPENWRONG] / 2); } } +#endif /* CHECKME: is this correct? */ if ((ds = fv1[HOPN])) @@ -2241,6 +2277,21 @@ ScorePosition(short side) ScoreCaptures(); } +#ifndef MINISHOGI +# define BLACKHOME_START 0 +# define BLACKHOME_END 26 +# define MIDDLEROW_START 36 +# define MIDDLEROW_END 44 +# define WHITEHOME_START 54 +# define WHITEHOME_END 80 +#else +# define BLACKHOME_START 0 +# define BLACKHOME_END 4 +# define MIDDLEROW_START 10 +# define MIDDLEROW_END 14 +# define WHITEHOME_START 19 +# define WHITEHOME_END 24 +#endif for (c1 = black, c2 = white; c1 <= white; c1++, c2--) { short n; @@ -2248,7 +2299,7 @@ ScorePosition(short side) fv1 = fvalue[c1]; /* Score fifth rank */ - for (sq = 36, n = 0; sq <= 44; sq++) + for (sq = MIDDLEROW_START, n = 0; sq <= MIDDLEROW_END; sq++) { if ((color[sq] == c1) || (attack[c1][sq] != 0)) n++; @@ -2260,8 +2311,8 @@ ScorePosition(short side) } /* Score holes */ - for (sq = ((c1 == black) ? 0 : 54), n = 0; - sq <= ((c1 == black) ? 26 : 80); + for (sq = ((c1 == black) ? BLACKHOME_START : WHITEHOME_START), n = 0; + sq <= ((c1 == black) ? BLACKHOME_END : WHITEHOME_END); sq++) { if (board[sq] == no_piece && attack[c1][sq] == 0) @@ -2310,6 +2361,7 @@ ScorePosition(short side) * Try to determine the game type of "side". */ +#ifndef MINISHOGI inline static void GuessGameType(short side_to_move) { @@ -2443,6 +2495,7 @@ GuessGameType(short side_to_move) } } } +#endif @@ -2452,7 +2505,13 @@ DetermineGameType(short side_to_move) { short side; +#ifndef MINISHOGI + /* FIXME: calculations below are wrong for minishogi, all done for 9x9 */ GuessGameType(side_to_move); +#else + GameType[black] = UNKNOWN; + GameType[white] = UNKNOWN; +#endif array_zero(Mpawn, sizeof(Mpawn)); #ifndef MINISHOGI @@ -2521,6 +2580,7 @@ ExaminePosition(short side) +/* FIXME: calculations below are wrong for minishogi, all done for 9x9 */ void DetermineStage(short side) {