Go to the documentation of this file.00001 #ifndef OSL_SAFE_DROP_MAJOR_PIECE_H
00002 #define OSL_SAFE_DROP_MAJOR_PIECE_H
00003 #include "osl/state/numEffectState.h"
00004 #include "osl/move_action/store.h"
00005 #include "osl/container/moveVector.h"
00006
00007 namespace osl
00008 {
00009 namespace move_generator
00010 {
00011 template <Player P>
00012 struct SafeDropMajorPiece
00013 {
00014 template <class Action>
00015 static void generate(const NumEffectState& state, Action& action)
00016 {
00017 const bool has_bishop = state.template hasPieceOnStand<BISHOP>(P);
00018 const bool has_rook = state.template hasPieceOnStand<ROOK>(P);
00019
00020 if (!has_rook && !has_bishop)
00021 return;
00022
00023 int start_y;
00024 if (P == BLACK)
00025 start_y = 1;
00026 else
00027 start_y = 7;
00028 for (int x = 1; x <= 9; x++)
00029 {
00030 for (int y = start_y; y < start_y + 3; y++)
00031 {
00032 Square position(x, y);
00033 if (state.pieceOnBoard(position).isEmpty()
00034 && !state.hasEffectAt(alt(P), position))
00035 {
00036 if (has_rook)
00037 {
00038 action.dropMove(position, ROOK, P);
00039 }
00040 if (has_bishop)
00041 {
00042 action.dropMove(position, BISHOP, P);
00043 }
00044 }
00045 }
00046 }
00047 }
00048 template <size_t Capacity>
00049 static void generateMoves(const NumEffectState& state,
00050 FixedCapacityVector<Move,Capacity>& out)
00051 {
00052 move_action::Store store(out);
00053 generate(state, store);
00054 }
00055 };
00056 }
00057 }
00058
00059 #endif
00060
00061
00062
00063