00001 /* shouldPromoteCut.h 00002 */ 00003 #ifndef _SEARCH_SHOULDPROMOTECUT_H 00004 #define _SEARCH_SHOULDPROMOTECUT_H 00005 00006 #include "osl/basic_type.h" 00007 #include "osl/bits/ptypeTable.h" 00008 namespace osl 00009 { 00016 struct ShouldPromoteCut 00017 { 00018 template <Player P> 00019 static bool canIgnore(Ptype ptype, Square from, Square to) 00020 { 00021 assert(! from.isPieceStand()); 00022 return (ptype==LANCE && (P==BLACK ? to.y()==2 : to.y()==8)) || 00023 (isBasic(ptype) && Ptype_Table.isBetterToPromote(ptype) 00024 && (to.canPromote<P>() || from.canPromote<P>())); 00025 } 00029 template <Player Moving> 00030 static bool canIgnoreMove(Move move) 00031 { 00032 assert(! move.isDrop()); 00033 return canIgnore<Moving>(move.ptype(), move.from(), move.to()); 00034 } 00038 template <Player Moving> 00039 static bool canIgnoreAndNotDrop(Move move) 00040 { 00041 return (! move.isDrop()) && canIgnoreMove<Moving>(move); 00042 } 00043 static bool canIgnoreAndNotDrop(Move move) 00044 { 00045 if (move.player() == BLACK) 00046 return canIgnoreAndNotDrop<BLACK>(move); 00047 else 00048 return canIgnoreAndNotDrop<WHITE>(move); 00049 } 00050 }; 00051 00052 00053 } // osl 00054 00055 #endif /* _SHOULDPROMOTECUT_H */ 00056 // ;;; Local Variables: 00057 // ;;; mode:c++ 00058 // ;;; c-basic-offset:2 00059 // ;;; End: