X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=gnushogi%2Fgenmove.c;h=208966d3a0fccb8bd4b0118c15186bdca7dfa54d;hb=1907f35d3370f971df16e40dec4135110386a84c;hp=8eb0e3d2185bd9717bda7c649296b2fb5bd607db;hpb=9009c8ba46a421e738d3ea57564e2df44dcaf3c5;p=gnushogi.git diff --git a/gnushogi/genmove.c b/gnushogi/genmove.c index 8eb0e3d..208966d 100644 --- a/gnushogi/genmove.c +++ b/gnushogi/genmove.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 * @@ -245,12 +246,12 @@ gives_check_flag(unsigned short *flags, short side, short f, short t) inline static void -Link(short side, short piece, +Link(short side, short from, short to, unsigned short local_flag, short s) { if (*TrP == TREE) { - ShowMessage("TREE overflow\n"); + dsp->ShowMessage("TREE overflow\n"); } else { @@ -326,8 +327,10 @@ PromotionPossible(short color, short f, short t, short p) switch (p) { case pawn: +#ifndef MINISHOGI case lance: case knight: +#endif case silver: case bishop: case rook: @@ -338,8 +341,8 @@ PromotionPossible(short color, short f, short t, short p) } -inline int -NonPromotionPossible(short color, short f, +static inline int +NonPromotionPossible(short color, short t, short p) { switch (p) @@ -358,6 +361,7 @@ NonPromotionPossible(short color, short f, : (generate_move_flags ? ILLEGAL_TRAPPED : false)); } +#ifndef MINISHOGI case lance: if (color == black) { @@ -385,6 +389,7 @@ NonPromotionPossible(short color, short f, ? true : (generate_move_flags ? ILLEGAL_TRAPPED : false)); } +#endif } return true; @@ -396,7 +401,7 @@ NonPromotionPossible(short color, short f, /* bonus for possible next moves */ inline static short -field_bonus(short ply, short side, short piece, +field_bonus(short side, short piece, short f, short t, unsigned short *local_flag) { short s, u, ptyp; @@ -533,7 +538,11 @@ field_bonus(short ply, short side, short piece, /* CHECKME: is this right? */ if (((rvupiece == rvuboard) && (upiece == pawn)) - || (upiece == bishop) || (upiece == knight)) + || (upiece == bishop) +#ifndef MINISHOGI + || (upiece == knight) +#endif + ) { s++; /* The opposing pawn (piece) */ @@ -612,7 +621,7 @@ LinkMove(short ply, short f, if (score_if_impossible < 0) { /* The move is flagged as illegal. */ - Link(side, piece, + Link(side, f, t, local_flag, score_if_impossible); return; @@ -721,7 +730,7 @@ LinkMove(short ply, short f, s -= 16 / Captured[side][silver]; #if defined DROPBONUS - s += field_bonus(ply, side, piece, f, t, &local_flag); + s += field_bonus(side, piece, f, t, &local_flag); if (s == 10 && piece != pawn) local_flag |= questionable; @@ -772,7 +781,11 @@ LinkMove(short ply, short f, { #ifdef TESUJIBONUS /* Look at non-promoting silver or knight */ - if (piece == silver || piece == knight) + if (piece == silver +#ifndef MINISHOGI + || piece == knight +#endif + ) { local_flag |= tesuji; /* Non-promotion */ s++; @@ -806,7 +819,7 @@ LinkMove(short ply, short f, else { #if defined FIELDBONUS - s += field_bonus(ply, side, piece, f, t, &local_flag); + s += field_bonus(side, piece, f, t, &local_flag); #endif } } @@ -858,7 +871,7 @@ LinkMove(short ply, short f, if (try_link || GenerateAllMoves) { - Link(side, piece, f, t, local_flag, + Link(side, f, t, local_flag, s - ((SCORE_LIMIT + 1000) * 2)); } @@ -908,6 +921,7 @@ DropPossible(short piece, short side, short sq) GenUnmakeMove(side, f, sq, tempb, tempc, false); } } +#ifndef MINISHOGI else if (piece == lance) { if ((side == black) && (r == 8)) @@ -922,6 +936,7 @@ DropPossible(short piece, short side, short sq) else if ((side == white) && (r <= 1)) possible = (generate_move_flags ? ILLEGAL_TRAPPED : false); } +#endif return possible; } @@ -1026,7 +1041,7 @@ GenMoves(short ply, short sq, short side, LinkMove(ply, sq, u, local_flag | promote, xside, true); if ((possible - = NonPromotionPossible(color[sq], sq, u, piece))) + = NonPromotionPossible(color[sq], u, piece))) { LinkMove(ply, sq, u, local_flag, xside, possible); } @@ -1110,9 +1125,13 @@ LinkPreventCheckDrops(short side, short xside, short ply) if (board[square = PieceList[side][0]] != king) return; - for (piece = lance; piece <= rook; piece++) /* FIXME */ + for (piece = pawn+1; piece <= rook; piece++) { - if (piece == lance || piece == bishop || piece == rook) + if ( +#ifndef MINISHOGI + piece == lance || +#endif + piece == bishop || piece == rook) { /* check for threat of xside piece */ ptyp = ptype[side][piece]; @@ -1478,7 +1497,7 @@ CaptureList(short side, short ply, if ((PP = PromotionPossible(color[sq], sq, u, piece))) { - Link(side, piece, + Link(side, sq, u, capture | promote, (*value)[stage][board[u]] #if !defined SAVE_SVALUE @@ -1489,7 +1508,7 @@ CaptureList(short side, short ply, if (!PP || flag.tsume) { - Link(side, piece, + Link(side, sq, u, capture, (*value)[stage][board[u]] #if !defined SAVE_SVALUE @@ -1639,7 +1658,7 @@ IsCheckmate(short side, short in_check, short blockable) * Drops are restricted for pawns, lances, and knights. */ - if (piece > knight) + if (piece >= silver) break; } }