| 1 |
/* checkFilter.h |
| 2 |
*/ |
| 3 |
#ifndef _MOVE_ACTION_CHECK_FILTER_H |
| 4 |
#define _MOVE_ACTION_CHECK_FILTER_H |
| 5 |
#include "osl/position.h" |
| 6 |
#include "osl/player.h" |
| 7 |
#include "osl/ptype.h" |
| 8 |
#include "osl/move_action/concept.h" |
| 9 |
#include "osl/move_classifier/check_.h" |
| 10 |
|
| 11 |
namespace osl |
| 12 |
{ |
| 13 |
namespace move_action |
| 14 |
{ |
| 15 |
|
| 16 |
/** |
| 17 |
* 自玉に王手がかかっていない状況から |
| 18 |
* 着手して自殺手になる手を除く |
| 19 |
*/ |
| 20 |
template<Player P,class OrigAction> |
| 21 |
struct CheckFilter |
| 22 |
{ |
| 23 |
BOOST_CLASS_REQUIRE(OrigAction,osl::move_action,Concept); |
| 24 |
const NumEffectState& state; |
| 25 |
OrigAction & action; |
| 26 |
public: |
| 27 |
CheckFilter(const NumEffectState& s, OrigAction & action) |
| 28 |
: state(s), action(action) { |
| 29 |
} |
| 30 |
void simpleMove(Square from,Square to,Ptype ptype, bool isPromote,Player p){ |
| 31 |
assert(p == P); |
| 32 |
typedef move_classifier::Check<P> check_t; |
| 33 |
if(check_t::isDirectCheck(state,ptype,to) || |
| 34 |
move_classifier::OpenCheck<P>::isMember(state,ptype,from,to)) |
| 35 |
action.simpleMove(from,to,ptype,isPromote,P); |
| 36 |
} |
| 37 |
void unknownMove(Square from,Square to,Piece p1,Ptype ptype,bool isPromote,Player p){ |
| 38 |
if(move_classifier::DirectCheck<P>::isMember(state,ptype,to) || |
| 39 |
move_classifier::OpenCheck<P>::isMember(state,ptype,from,to)) |
| 40 |
action.unknownMove(from,to,p1,ptype,isPromote,P); |
| 41 |
} |
| 42 |
void dropMove(Square to,Ptype ptype,Player p){ |
| 43 |
assert(p == P); |
| 44 |
if(move_classifier::DirectCheck<P>::isMember(state,ptype,to)) |
| 45 |
action.dropMove(to,ptype,P); |
| 46 |
} |
| 47 |
}; |
| 48 |
} // namespace move_action |
| 49 |
} // namespace osl |
| 50 |
|
| 51 |
#endif /* _MOVE_ACTION_CHECK_FILTER_H */ |
| 52 |
// ;;; Local Variables: |
| 53 |
// ;;; mode:c++ |
| 54 |
// ;;; c-basic-offset:2 |
| 55 |
// ;;; End: |