29 using namespace move_classifier;
31 const Player attacker = state.turn();
33 const Square king = state.kingSquare(defender);
34 PieceMask pieces = state.effectSetAt(move.
to())
35 & state.piecesOnBoard(defender);
38 if (Neighboring8::isNeighboring8(move.
to(), king))
47 && (state.longEffectAt(move.
from(), attacker).any()
48 || (Neighboring8::isNeighboring8(move.
from(), king)
49 && state.hasEffectAt(attacker, move.
from()))))
52 const King8Info info = state.king8Info(defender);
53 const CArray<Square,2> knight_position = {{
58 && (info.dropCandidate() || info.moveCandidate2()
59 || info.liberty() == 0))
62 if (info.dropCandidate())
64 if (info.liberty() == 0) {
65 for (
int i=0; i<2; ++i) {
66 const Square kp = knight_position[i];
67 const Piece kpp = state.pieceAt(kp);
73 if (state.hasEffectByPiece(
captured, kp)
75 || state.hasPieceOnStand<
KNIGHT>(attacker)
76 || state.hasEffectByPtypeStrict<
KNIGHT>(attacker, kp)))
80 }
else if (info.liberty() == 0 && state.hasPieceOnStand<
KNIGHT>(attacker)) {
81 for (
int i=0; i<2; ++i) {
82 const Square kp = knight_position[i];
83 const Piece kpp = state.pieceAt(kp);
86 if (state.hasEffectByPiece(kpp, move.
to()))
93 const Piece p=state.pieceOf(pieces.takeOneBit());
94 if (Neighboring8Direct::hasEffectOrAdditional(state, p.
ptypeO(), p.
square(), king)
95 || Neighboring8::isNeighboring8(p.
square(), king))
97 if (state.longEffectAt(p.
square(), attacker).any())
99 if (info.liberty() == 0) {
102 const Square kp = knight_position[i];
103 const Piece kpp = state.pieceAt(kp);
104 if (kpp.
isEdge() || state.hasEffectNotBy(defender, p, kp))
107 && state.hasPieceOnStand<
KNIGHT>(attacker))
109 if (state.countEffect(defender, kp) == 1)
111 && state.hasEffectByPtypeStrict<
KNIGHT>(attacker, kp))
113 && state.hasPieceOnStand<
KNIGHT>(attacker)))
128 assert(move.
player() == state.turn());
130 state.makeUnmakeMove(move, defense);
132 if (defense.result && ! effectiveAttackCandidate0(state, move))
133 std::cerr << state << move <<
"\n", assert(0);
135 return defense.result;
142 if (state.inCheck(
alt(state.turn())))
145 using namespace move_generator;
146 using namespace move_action;
154 const Square king = state.kingSquare(state.turn());
155 for (MoveVector::const_iterator p=
moves.begin(); p!=
moves.end(); ++p)
157 if (state.inCheck()) {
158 if (state.countEffect(
alt(state.turn()), king) > 1
159 || ! state.hasEffectByPiece(state.pieceOnBoard(last_to), king))
160 if (p->ptype() !=
KING)