shouldPromoteCut.h
Go to the documentation of this file.
00001 /* shouldPromoteCut.h
00002  */
00003 #ifndef _SEARCH_SHOULDPROMOTECUT_H
00004 #define _SEARCH_SHOULDPROMOTECUT_H
00005 
00006 #include "osl/ptypeTable.h"
00007 #include "osl/player.h"
00008 #include "osl/move.h"
00009 namespace osl
00010 {
00011   namespace search
00012   {
00019     struct ShouldPromoteCut
00020     {
00021       template <Player P>
00022       static bool canIgnore(Ptype ptype, Square from, Square to)
00023       {
00024         assert(! from.isPieceStand());
00025         return (ptype==LANCE && (P==BLACK ? to.y()==2 : to.y()==8)) ||
00026           (isBasic(ptype) && Ptype_Table.isBetterToPromote(ptype)
00027            && (to.canPromote<P>() || from.canPromote<P>()));
00028       }
00032       template <Player Moving>
00033       static bool canIgnoreMove(Move move)
00034       {
00035         assert(! move.isDrop());
00036         return canIgnore<Moving>(move.ptype(), move.from(), move.to());
00037       }
00041       template <Player Moving>
00042       static bool canIgnoreAndNotDrop(Move move)
00043       {
00044         return (! move.isDrop()) && canIgnoreMove<Moving>(move);
00045       }
00046       static bool canIgnoreAndNotDrop(Move move)
00047       {
00048         if (move.player() == BLACK)
00049           return canIgnoreAndNotDrop<BLACK>(move);
00050         else
00051           return canIgnoreAndNotDrop<WHITE>(move);
00052       }
00053     };
00054     
00055 
00056   } // namespace search
00057 } // osl
00058 
00059 #endif /* _SHOULDPROMOTECUT_H */
00060 // ;;; Local Variables:
00061 // ;;; mode:c++
00062 // ;;; c-basic-offset:2
00063 // ;;; End:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines