00001 #ifndef _GENERATE_SAFE_DROP_MAJOR_PIECE_H
00002 #define _GENERATE_SAFE_DROP_MAJOR_PIECE_H
00003 #include "osl/player.h"
00004 #include "osl/ptype.h"
00005 #include "osl/position.h"
00006
00007 namespace osl
00008 {
00009 namespace move_generator
00010 {
00011 template <Player P>
00012 struct SafeDropMajorPiece
00013 {
00014 template <class State, class Action>
00015 static void generate(const State& state, Action& action)
00016 {
00017 const bool has_bishop = state.template hasPieceOnStand<P,BISHOP>();
00018 const bool has_rook = state.template hasPieceOnStand<P,ROOK>();
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 Position position(x, y);
00033 if (state.getPieceOnBoard(position).isEmpty()
00034 && !state.hasEffectBy(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 };
00049 }
00050 }
00051
00052 #endif
00053
00054
00055
00056