additionalLance.cc
Go to the documentation of this file.
00001 /* additionalLance.cc
00002  */
00003 #include "osl/move_generator/additionalLance.h"
00004 #include "osl/container/moveVector.h"
00005 
00006 
00007 template <osl::Player P>
00008 void osl::move_generator::AdditionalLance<P>::
00009 generate(const NumEffectState& state, Square pawn, MoveVector& out)
00010 {
00011   assert((state.hasPieceOnStand<LANCE>(P)));
00012   assert(state.pieceOnBoard(pawn).ptype() == PAWN);
00013   Square back_position = pawn + DirectionPlayerTraits<D,P>::offset();
00014   Piece target = state.pieceAt(back_position);
00015   while (target.isEmpty())
00016   {
00017     if (state.hasEffectAt<PlayerTraits<P>::opponent>(back_position))
00018       break;
00019     out.push_back(Move(back_position, LANCE, P));
00020           
00021     back_position = back_position + DirectionPlayerTraits<D,P>::offset();
00022     target = state.pieceAt(back_position);
00023   }     
00024 }
00025 
00026 template <osl::Player P>
00027 void osl::move_generator::AdditionalLance<P>::
00028 generateIfHasLance(const NumEffectState& state, Square pawn, 
00029                    MoveVector& out)
00030 {
00031   if (state.hasPieceOnStand<LANCE>(P))
00032     generate(state, pawn, out);
00033 }
00034 namespace osl
00035 {
00036   namespace move_generator
00037   {
00038     template struct AdditionalLance<BLACK>;
00039     template struct AdditionalLance<WHITE>;
00040   }
00041 }
00042 
00043 /* ------------------------------------------------------------------------- */
00044 // ;;; Local Variables:
00045 // ;;; mode:c++
00046 // ;;; c-basic-offset:2
00047 // ;;; End:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines