captureEffectToAroundKing8.h
Go to the documentation of this file.
00001 #ifndef _GENERATE_CAPTURE_EFFECT_TO_AROUND_KING8_H
00002 #define _GENERATE_CAPTURE_EFFECT_TO_AROUND_KING8_H
00003 #include "osl/move_generator/pieceOnBoard.h"
00004 #include "osl/move_action/captureFrom.h"
00005 #include "osl/move_action/store.h"
00006 #include "osl/centering3x3.h"
00007 #include "osl/state/numEffectState.h"
00008 #include "osl/container/moveVector.h"
00009 
00010 namespace osl
00011 {
00012   namespace move_generator
00013   {
00020     template <Player P>
00021     struct CaptureEffectToAroundKing8
00022     {
00023       template <class Action>
00024       static void generateTo(const NumEffectState& state,
00025                              Square p,
00026                              Action& action)
00027       {
00028         typedef move_action::CaptureFrom<P, Action>
00029           capture_action;
00030         capture_action capture(state, action);
00031           
00032         if (p.isEdge()) return;
00033         assert(p.isOnBoard());
00034 
00035         state.template forEachEffect<PlayerTraits<P>::opponent,
00036           capture_action>(p, capture);
00037       }
00038 
00039       static void generate(const NumEffectState& state, MoveVector& moves)
00040       {
00041         const Square position_king = 
00042           Centering3x3::adjustCenter(state.template kingSquare<P>());
00043         {
00044         move_action::Store action(moves);
00045         generateTo(state,
00046                    position_king,
00047                    action);
00048         generateTo(state,
00049                    position_king + Board_Table.getOffsetForBlack(UL),
00050                    action);
00051         generateTo(state,
00052                    position_king + Board_Table.getOffsetForBlack(U),
00053                    action);
00054         generateTo(state,
00055                    position_king + Board_Table.getOffsetForBlack(UR),
00056                    action);
00057         generateTo(state,
00058                    position_king + Board_Table.getOffsetForBlack(L),
00059                    action);
00060         generateTo(state,
00061                    position_king + Board_Table.getOffsetForBlack(R),
00062                    action);
00063         generateTo(state,
00064                    position_king + Board_Table.getOffsetForBlack(DL),
00065                    action);
00066         generateTo(state,
00067                    position_king + Board_Table.getOffsetForBlack(D),
00068                    action);
00069         generateTo(state,
00070                    position_king + Board_Table.getOffsetForBlack(DR),
00071                    action);
00072         }
00073         moves.unique();
00074       }
00075       
00076     };
00077   }
00078 } // namespace osl
00079 
00080 #endif /* _GENERATE_CAPTURE_EFFECT_TO_AROUND_KING8_H */
00081 // ;;; Local Variables:
00082 // ;;; mode:c++
00083 // ;;; c-basic-offset:2
00084 // ;;; End:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines