oracleAdjust.h
Go to the documentation of this file.
/* oracleAdjust.h
*/
#ifndef _ORACLEADUST_H
#define _ORACLEADUST_H
#include "osl/numEffectState.h"
namespace osl
{
namespace checkmate
{
struct OracleAdjust
{
static const Move attack(const NumEffectState& state, Move check_move)
{
assert(check_move.isValid());
if (! check_move.isDrop())
{
// capture
{
const Piece p=state.pieceOnBoard(check_move.to());
if (p.isPtype<KING>())
return Move();
check_move=check_move.newCapture(p);
}
// from
if (state.pieceOnBoard(check_move.from()).ptype() != check_move.oldPtype()
&& Ptype_Table.hasLongMove(check_move.ptype())) {
Piece p;
switch (unpromote(check_move.ptype())) {
case ROOK:
{
mask_t m = state.allEffectAt<ROOK>(check_move.player(), check_move.to());
while (m.any()) {
const int num = m.takeOneBit()+PtypeFuns<ROOK>::indexNum*32;
p = state.pieceOf(num);
if (Board_Table.getShortOffsetNotKnight(Offset32(check_move.to(), check_move.from()))
== Board_Table.getShortOffsetNotKnight(Offset32(check_move.to(), p.square())))
break;
}
break;
}
case BISHOP:
{
mask_t m = state.allEffectAt<BISHOP>(check_move.player(), check_move.to());
while (m.any()) {
const int num = m.takeOneBit()+PtypeFuns<BISHOP>::indexNum*32;
p = state.pieceOf(num);
if (Board_Table.getShortOffsetNotKnight(Offset32(check_move.to(), check_move.from()))
== Board_Table.getShortOffsetNotKnight(Offset32(check_move.to(), p.square())))
break;
}
break;
}
case LANCE: p = state.findAttackAt<LANCE>(check_move.player(), check_move.to());
break;
default:
assert(0);
}
if (p.isPiece()) {
if (check_move.oldPtype() == p.ptype())
check_move=check_move.newFrom(p.square());
else if (check_move.ptype() == p.ptype())
check_move = Move(p.square(), check_move.to(), check_move.ptype(),
check_move.capturePtype(), false, check_move.player());
if (! state.isValidMoveByRule(check_move, false))
return Move();
}
}
}
if (! state.isAlmostValidMove<false>(check_move))
return Move();
return check_move;
}
};
}
}
#endif /* _ORACLEADUST_H */
// ;;; Local Variables:
// ;;; mode:c++
// ;;; c-basic-offset:2
// ;;; End:
osl::Move
圧縮していない moveの表現 .
Definition basic_type.h:1052
osl::Move::isValid
bool isValid() const
Definition basic_type.cc:246
osl::Move::ptype
Ptype ptype() const
Definition basic_type.h:1155
osl::Move::player
Player player() const
Definition basic_type.h:1195
osl::Move::isDrop
bool isDrop() const
Definition basic_type.h:1150
osl::Move::capturePtype
Ptype capturePtype() const
Definition basic_type.h:1180
osl::Move::newCapture
const Move newCapture(Piece capture) const
Definition basic_type.h:1231
osl::Move::newFrom
Move newFrom(Square new_from) const
Definition basic_type.h:1207
osl::Move::oldPtype
Ptype oldPtype() const
移動前のPtype, i.e., 成る手だった場合成る前
Definition basic_type.h:1174
osl::Move::to
const Square to() const
Definition basic_type.h:1132
osl::Move::from
const Square from() const
Definition basic_type.h:1125
osl::NumEffectState
利きを持つ局面
Definition numEffectState.h:34
osl::NumEffectState::isAlmostValidMove
bool isAlmostValidMove(Move move) const
合法手かどうかを簡単に検査する．局面に依存するチェックのみ． ルール上指せない手である可能性がある場合は，isValidMove を用いる．
Definition numEffectState.cc:823
osl::NumEffectState::findAttackAt
const Piece findAttackAt(Player attack, Square target) const
return a piece s.t.
Definition numEffectState.h:503
osl::NumEffectState::allEffectAt
const mask_t allEffectAt(Player P, Square target) const
Definition numEffectState.h:293
osl::Piece
駒.
Definition basic_type.h:788
osl::Piece::ptype
Ptype ptype() const
Definition basic_type.h:821
osl::Piece::square
const Square square() const
Definition basic_type.h:832
osl::Piece::isPiece
bool isPiece() const
Definition basic_type.h:953
osl::Piece::isPtype
bool isPtype() const
Definition basic_type.h:930
osl::SimpleState::pieceOnBoard
const Piece pieceOnBoard(Square sq) const
Definition simpleState.h:170
osl::SimpleState::isValidMoveByRule
static bool isValidMoveByRule(Move move, bool show_error)
盤面以外の部分の反則のチェック
Definition simpleState.cc:372
osl::SimpleState::pieceOf
const Piece pieceOf(int num) const
Definition simpleState.h:76
osl::misc::GeneralMask::any
bool any() const
Definition mask.h:298
osl::misc::GeneralMask::takeOneBit
int takeOneBit()
non-zeroのmaskのsetされているビットをLSBから探し，その番号を返す 副作用としてmaskの対応するビットをクリアする
Definition mask.h:265
osl::checkmate
Definition king8Info.h:12
osl::misc::mask_t
GeneralMask< mask_int_t > mask_t
Definition mask.h:351
osl
Definition additionalEffect.h:6
osl::ROOK
@ ROOK
Definition basic_type.h:100
osl::BISHOP
@ BISHOP
Definition basic_type.h:99
osl::KING
@ KING
Definition basic_type.h:93
osl::LANCE
@ LANCE
Definition basic_type.h:96
osl::Ptype_Table
const PtypeTable Ptype_Table
Definition tables.cc:97
osl::unpromote
Ptype unpromote(Ptype ptype)
ptypeがpromote後の型の時に，promote前の型を返す． promoteしていない型の時はそのまま返す
Definition basic_type.h:157
osl::Board_Table
const BoardTable Board_Table
Definition tables.cc:95
osl::Offset32
Offset32Base< 8, 9 > Offset32
Definition offset32.h:63
numEffectState.h
osl::PtypeFuns
Definition ptypeTraits.h:311
osl::checkmate::OracleAdjust
Definition oracleAdjust.h:13
osl::checkmate::OracleAdjust::attack
static const Move attack(const NumEffectState &state, Move check_move)
Definition oracleAdjust.h:14