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
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:
int countEffect(Player player, Square target) const
利きの数を数える.
bool isOnBoardByOwner() const
piece がプレイヤーPの持ち物でかつボード上にある駒の場合は true.
Definition: basic_type.h:852
bool hasEffectAt(Square target) const
対象とするマスにあるプレイヤーの利きがあるかどうか.
constexpr Player alt(Player player)
Definition: basic_type.h:13
const Piece pieceAt(Square sq) const
Definition: simpleState.h:167
送り金のような玉で取ると利きがはずれる駒が発生するマスを調査
Definition: sendOffSquare.h:16
利きを持つ局面
static void testSquare(const NumEffectState &state, Square candidate, int id, int &out)
Definition: sendOffSquare.h:47
Player
Definition: basic_type.h:8
CArray< Offset8, 256 > reverse_all
Definition: sendOffSquare.h:40
static bool onlyOneSupport(const NumEffectState &state, Square target)
Definition: sendOffSquare.h:20