X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=gnushogi%2Fgenmove.c;h=2f4db1b6a6d32f28b872313eda55269299c6b017;hb=ef305e06b93ed27dd376c1f3ea8e0a7041a73943;hp=ae919390790e9e36cc6a2b7c03c99f655935b9ff;hpb=68c554411d120d163045f77a80ad9009f7a73841;p=gnushogi.git diff --git a/gnushogi/genmove.c b/gnushogi/genmove.c index ae91939..2f4db1b 100644 --- a/gnushogi/genmove.c +++ b/gnushogi/genmove.c @@ -246,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 { @@ -323,26 +323,12 @@ PromotionPossible(short color, short f, short t, short p) return false; } - /* FIXME: this can be simplified... */ - switch (p) - { - case pawn: -#ifndef MINISHOGI - case lance: - case knight: -#endif - case silver: - case bishop: - case rook: - return true; - }; - - return false; + return (typeMask[p] & (T_PAWN|T_LANCE|T_KNIGHT|T_SILVER|T_BISHOP|T_ROOK)) != 0; } -inline int -NonPromotionPossible(short color, short f, +static inline int +NonPromotionPossible(short color, short t, short p) { switch (p) @@ -350,13 +336,21 @@ NonPromotionPossible(short color, short f, case pawn : if (color == black) { +#ifdef MINISHOGI + return ((t < 20) +#else return ((t < 72) +#endif ? true : (generate_move_flags ? ILLEGAL_TRAPPED : false)); } else { +#ifdef MINISHOGI + return ((t > 4) +#else return ((t > 8) +#endif ? true : (generate_move_flags ? ILLEGAL_TRAPPED : false)); } @@ -401,7 +395,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; @@ -538,10 +532,7 @@ field_bonus(short ply, short side, short piece, /* CHECKME: is this right? */ if (((rvupiece == rvuboard) && (upiece == pawn)) - || (upiece == bishop) -#ifndef MINISHOGI - || (upiece == knight) -#endif + || typeMask[upiece] & (T_BISHOP | T_KNIGHT) ) { s++; /* The opposing pawn (piece) */ @@ -621,7 +612,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; @@ -730,7 +721,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; @@ -781,11 +772,7 @@ LinkMove(short ply, short f, { #ifdef TESUJIBONUS /* Look at non-promoting silver or knight */ - if (piece == silver -#ifndef MINISHOGI - || piece == knight -#endif - ) + if (typeMask[piece] & (T_SILVER | T_KNIGHT)) { local_flag |= tesuji; /* Non-promotion */ s++; @@ -819,7 +806,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 } } @@ -871,7 +858,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)); } @@ -1041,7 +1028,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); } @@ -1127,11 +1114,7 @@ LinkPreventCheckDrops(short side, short xside, short ply) for (piece = pawn+1; piece <= rook; piece++) { - if ( -#ifndef MINISHOGI - piece == lance || -#endif - piece == bishop || piece == rook) + if (typeMask[piece] & (T_LANCE | T_BISHOP | T_ROOK)) { /* check for threat of xside piece */ ptyp = ptype[side][piece]; @@ -1497,7 +1480,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 @@ -1508,7 +1491,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