sendOffSquare.h
Go to the documentation of this file.
/* sendOffSquare.h
*/
#ifndef OSL_SENDOFFPOSITION_H
#define OSL_SENDOFFPOSITION_H
#include "osl/numEffectState.h"
#include "osl/container/square8.h"
namespace osl
{
namespace effect_util
{
struct Offset8 : public FixedCapacityVector<int,8>
{
};
struct SendOffSquare
{
typedef uint8_t SendOff8;
template <Player Attack>
static bool onlyOneSupport(const NumEffectState& state, Square target)
{
const Piece p = state.pieceAt(target);
if (! p.isOnBoardByOwner<alt(Attack)>())
return false;
return state.hasEffectAt<Attack>(target)
&& (state.countEffect(alt(Attack), target) == 1);
}
template <Player Attack>
static SendOff8 find(const NumEffectState& state, Square king_position,
Square8& out);
static SendOff8 find(Player attack,
const NumEffectState& state, Square king_position,
Square8& out);
static SendOff8 invalidData() { return 0xff; }
static void unpack(SendOff8, Square king, Square8& out);
struct Table
{
CArray<Offset,8> normal;
CArray<Offset8,8> reverse;
CArray<Offset8,256> reverse_all;
void init();
};
static void init() { table.init(); }
private:
static Table table;
template <Player Attack>
static void testSquare(const NumEffectState& state, Square candidate,
int id, int& out)
{
if (onlyOneSupport<Attack>(state, candidate))
{
out |= (1<<id);
}
}
};
} // namespace effect_util
using effect_util::SendOffSquare;
} // namespace osl
#endif /* OSL_SENDOFFPOSITION_H */
// ;;; Local Variables:
// ;;; mode:c++
// ;;; c-basic-offset:2
// ;;; coding:utf-8
// ;;; End:
osl::CArray
Definition container.h:20
osl::FixedCapacityVector< int, 8 >::FixedCapacityVector
FixedCapacityVector()
Definition container.h:159
osl::NumEffectState
利きを持つ局面
Definition numEffectState.h:34
osl::NumEffectState::countEffect
int countEffect(Player player, Square target) const
利きの数を数える.
Definition numEffectState.h:266
osl::NumEffectState::hasEffectAt
bool hasEffectAt(Square target) const
対象とするマスにあるプレイヤーの利きがあるかどうか.
Definition numEffectState.h:324
osl::Piece
駒.
Definition basic_type.h:788
osl::Piece::isOnBoardByOwner
bool isOnBoardByOwner() const
piece がプレイヤーPの持ち物でかつボード上にある駒の場合は true.
Definition basic_type.h:852
osl::SimpleState::pieceAt
const Piece pieceAt(Square sq) const
Definition simpleState.h:167
osl::Square
Definition basic_type.h:532
osl::effect_util
Definition additionalEffect.h:8
osl
Definition additionalEffect.h:6
osl::Player
Player
Definition basic_type.h:8
osl::alt
constexpr Player alt(Player player)
Definition basic_type.h:13
numEffectState.h
square8.h
osl::SendOffSquare::Table::init
void init()
Definition sendOffSquare.cc:14
osl::container::Square8
Definition square8.h:16
osl::effect_util::Offset8
Definition sendOffSquare.h:13
osl::effect_util::SendOffSquare::Table
Definition sendOffSquare.h:37
osl::effect_util::SendOffSquare::Table::reverse
CArray< Offset8, 8 > reverse
Definition sendOffSquare.h:39
osl::effect_util::SendOffSquare::Table::reverse_all
CArray< Offset8, 256 > reverse_all
Definition sendOffSquare.h:40
osl::effect_util::SendOffSquare::Table::normal
CArray< Offset, 8 > normal
Definition sendOffSquare.h:38
osl::effect_util::SendOffSquare
送り金のような玉で取ると利きがはずれる駒が発生するマスを調査
Definition sendOffSquare.h:17
osl::effect_util::SendOffSquare::SendOff8
uint8_t SendOff8
Definition sendOffSquare.h:18
osl::effect_util::SendOffSquare::init
static void init()
Definition sendOffSquare.h:43
osl::effect_util::SendOffSquare::invalidData
static SendOff8 invalidData()
Definition sendOffSquare.h:34
osl::effect_util::SendOffSquare::unpack
static void unpack(SendOff8, Square king, Square8 &out)
Definition sendOffSquare.cc:91
osl::effect_util::SendOffSquare::find
static SendOff8 find(const NumEffectState &state, Square king_position, Square8 &out)
osl::effect_util::SendOffSquare::onlyOneSupport
static bool onlyOneSupport(const NumEffectState &state, Square target)
Definition sendOffSquare.h:20
osl::effect_util::SendOffSquare::testSquare
static void testSquare(const NumEffectState &state, Square candidate, int id, int &out)
Definition sendOffSquare.h:47
osl::effect_util::SendOffSquare::table
static Table table
Definition sendOffSquare.h:45