kingOpenMove.cc
Go to the documentation of this file.
00001 #include "osl/move_classifier/kingOpenMove.h"
00002 #include "osl/state/numEffectState.h"
00003 
00004 template <osl::Player P>
00005 template <bool hasException>
00006 bool osl::move_classifier::KingOpenMove<P>::
00007 isMemberMain(const NumEffectState& state, Ptype, Square from, Square to,
00008              Square exceptFor)
00009 {
00010   assert(! from.isPieceStand());
00011   Square king_position=state.template kingSquare<P>();
00012   if (king_position.isPieceStand())
00013     return false;
00017   assert(king_position != from);
00021   Offset offset=Board_Table.getShortOffsetNotKnight(Offset32(king_position,from));
00026   if(offset.zero() ||
00027      offset==Board_Table.getShortOffsetNotKnight(Offset32(king_position,to)))
00028     return false;
00029   if(!state.isEmptyBetween(from,king_position,offset,true)) return false;
00030   Square pos=from;
00031   Piece p;
00032   for(pos-=offset;;pos-=offset){
00033     // TODO: exceptFor を毎回チェックする必要があるのはoffset方向の時だけ
00034     if (! ((hasException && (pos == exceptFor)) 
00035            || (p=state.pieceAt(pos), p.isEmpty())))
00036       break;
00037     assert(pos.isOnBoard());
00038   }
00043   if (! p.isOnBoardByOwner<PlayerTraits<P>::opponent>())
00044     return false;
00045   return Ptype_Table.getEffect(p.ptypeO(),pos,king_position).hasEffect();
00046 }
00047 
00048 namespace osl
00049 {
00050   // explicit template instantiation
00051   template struct move_classifier::KingOpenMove<BLACK>;
00052   template struct move_classifier::KingOpenMove<WHITE>;
00053 
00054   template bool move_classifier::KingOpenMove<BLACK>::isMemberMain<true>(const NumEffectState&, Ptype,Square,Square,Square);
00055   template bool move_classifier::KingOpenMove<BLACK>::isMemberMain<false>(const NumEffectState&, Ptype,Square,Square,Square);
00056   template bool move_classifier::KingOpenMove<WHITE>::isMemberMain<true>(const NumEffectState&, Ptype,Square,Square,Square);
00057   template bool move_classifier::KingOpenMove<WHITE>::isMemberMain<false>(const NumEffectState&, Ptype,Square,Square,Square);
00058 }
00059 
00060 // ;;; Local Variables:
00061 // ;;; mode:c++
00062 // ;;; c-basic-offset:2
00063 // ;;; End:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines