My Project
sendOffSquare.h
Go to the documentation of this file.
1 /* sendOffSquare.h
2  */
3 #ifndef OSL_SENDOFFPOSITION_H
4 #define OSL_SENDOFFPOSITION_H
5 
6 #include "osl/numEffectState.h"
8 namespace osl
9 {
10  namespace effect_util
11  {
12  struct Offset8 : public FixedCapacityVector<int,8>
13  {
14  };
17  {
18  typedef uint8_t SendOff8;
19  template <Player Attack>
20  static bool onlyOneSupport(const NumEffectState& state, Square target)
21  {
22  const Piece p = state.pieceAt(target);
23  if (! p.isOnBoardByOwner<alt(Attack)>())
24  return false;
25  return state.hasEffectAt<Attack>(target)
26  && (state.countEffect(alt(Attack), target) == 1);
27  }
28  template <Player Attack>
29  static SendOff8 find(const NumEffectState& state, Square king_position,
30  Square8& out);
31  static SendOff8 find(Player attack,
32  const NumEffectState& state, Square king_position,
33  Square8& out);
34  static SendOff8 invalidData() { return 0xff; }
35  static void unpack(SendOff8, Square king, Square8& out);
36  struct Table
37  {
41  void init();
42  };
43  static void init() { table.init(); }
44  private:
45  static Table table;
46  template <Player Attack>
47  static void testSquare(const NumEffectState& state, Square candidate,
48  int id, int& out)
49  {
50  if (onlyOneSupport<Attack>(state, candidate))
51  {
52  out |= (1<<id);
53  }
54  }
55  };
56  } // namespace effect_util
57  using effect_util::SendOffSquare;
58 } // namespace osl
59 
60 #endif /* OSL_SENDOFFPOSITION_H */
61 // ;;; Local Variables:
62 // ;;; mode:c++
63 // ;;; c-basic-offset:2
64 // ;;; coding:utf-8
65 // ;;; End:
osl::SimpleState::pieceAt
const Piece pieceAt(Square sq) const
Definition: simpleState.h:167
osl::Square
Definition: basic_type.h:532
osl::alt
constexpr Player alt(Player player)
Definition: basic_type.h:13
osl::FixedCapacityVector
Definition: container.h:137
osl::NumEffectState::hasEffectAt
bool hasEffectAt(Square target) const
対象とするマスにあるプレイヤーの利きがあるかどうか.
Definition: numEffectState.h:324
osl::Piece
駒.
Definition: basic_type.h:788
osl::effect_util::SendOffSquare::find
static SendOff8 find(const NumEffectState &state, Square king_position, Square8 &out)
osl::effect_util::SendOffSquare::SendOff8
uint8_t SendOff8
Definition: sendOffSquare.h:18
osl::effect_util::SendOffSquare::testSquare
static void testSquare(const NumEffectState &state, Square candidate, int id, int &out)
Definition: sendOffSquare.h:47
osl::Piece::isOnBoardByOwner
bool isOnBoardByOwner() const
piece がプレイヤーPの持ち物でかつボード上にある駒の場合は true.
Definition: basic_type.h:852
osl::effect_util::SendOffSquare::Table::reverse
CArray< Offset8, 8 > reverse
Definition: sendOffSquare.h:39
osl::effect_util::SendOffSquare::Table
Definition: sendOffSquare.h:37
osl::container::Square8
Definition: square8.h:16
osl::effect_util::SendOffSquare::init
static void init()
Definition: sendOffSquare.h:43
osl::effect_util::SendOffSquare::table
static Table table
Definition: sendOffSquare.h:45
osl::NumEffectState
利きを持つ局面
Definition: numEffectState.h:34
osl::effect_util::SendOffSquare::onlyOneSupport
static bool onlyOneSupport(const NumEffectState &state, Square target)
Definition: sendOffSquare.h:20
osl::effect_util::SendOffSquare::Table::reverse_all
CArray< Offset8, 256 > reverse_all
Definition: sendOffSquare.h:40
square8.h
osl::effect_util::Offset8
Definition: sendOffSquare.h:13
osl::effect_util::SendOffSquare::Table::normal
CArray< Offset, 8 > normal
Definition: sendOffSquare.h:38
osl::Player
Player
Definition: basic_type.h:8
numEffectState.h
osl::CArray
Definition: container.h:20
osl::effect_util::SendOffSquare::Table::init
void init()
Definition: sendOffSquare.cc:14
osl::effect_util::SendOffSquare::invalidData
static SendOff8 invalidData()
Definition: sendOffSquare.h:34
osl::NumEffectState::countEffect
int countEffect(Player player, Square target) const
利きの数を数える.
Definition: numEffectState.h:266
osl::effect_util::SendOffSquare::unpack
static void unpack(SendOff8, Square king, Square8 &out)
Definition: sendOffSquare.cc:91
osl::effect_util::SendOffSquare
送り金のような玉で取ると利きがはずれる駒が発生するマスを調査
Definition: sendOffSquare.h:17
osl
Definition: additionalEffect.h:6