X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=gnushogi%2Fgenmove.c;h=2f4db1b6a6d32f28b872313eda55269299c6b017;hb=ef305e06b93ed27dd376c1f3ea8e0a7041a73943;hp=d42c1d6cb8c19b8f7c9df0496da6c433dc48aebd;hpb=916e9d3b3acd6422ad21f8edbbe5da768737f2b8;p=gnushogi.git diff --git a/gnushogi/genmove.c b/gnushogi/genmove.c index d42c1d6..2f4db1b 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 * @@ -322,21 +323,7 @@ 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; } @@ -349,13 +336,21 @@ NonPromotionPossible(short color, 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)); } @@ -537,10 +532,7 @@ field_bonus(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) */ @@ -780,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++; @@ -1126,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];