My Project
additionalOrShadow.h
Go to the documentation of this file.
1 /* additionalOrShadow.h
2  */
3 #ifndef OSL_ADDITIONALORSHADOW_H
4 #define OSL_ADDITIONALORSHADOW_H
5 
6 #include "osl/numEffectState.h"
7 #include "osl/bits/boardTable.h"
8 
9 namespace osl
10 {
11  namespace effect_util
12  {
14  {
15  template <int count_max>
16  static int count(const PieceVector& direct_pieces,
17  const NumEffectState& state,
18  Square target, Player attack)
19  {
20  int result=0;
21  for (Piece p: direct_pieces)
22  {
23  const Square from = p.square();
24  int num = p.number();
25  const Direction long_d=Board_Table.getLongDirection<BLACK>(Offset32(target,from));
26  if(!isLong(long_d)) continue; // unpromoted Knightを除いておくのとどちらが得か?
27  Direction d=longToShort(long_d);
28  for(;;){
29  num=state.longEffectNumTable()[num][d];
30  if(Piece::isEmptyNum(num) || state.pieceOf(num).owner()!=attack)
31  break;
32  if (++result >= count_max)
33  return result;
34  }
35  }
36  return result;
37  }
38 
39  };
40  }
41 } // namespace osl
42 
43 #endif /* OSL_ADDITIONALORSHADOW_H */
44 // ;;; Local Variables:
45 // ;;; mode:c++
46 // ;;; c-basic-offset:2
47 // ;;; coding:utf-8
48 // ;;; End:
Direction getLongDirection(Offset32 offset32) const
Definition: boardTable.h:71
利きを持つ局面
const EffectedNumTable & longEffectNumTable() const
Player owner() const
Definition: basic_type.h:963
static bool isEmptyNum(int num)
Definition: basic_type.h:916
const Piece pieceOf(int num) const
Definition: simpleState.h:76
unsigned int square
Definition: basic_type.h:533
constexpr Direction longToShort(Direction d)
Definition: basic_type.h:380
const BoardTable Board_Table
Definition: tables.cc:95
Direction
Definition: basic_type.h:310
Offset32Base< 8, 9 > Offset32
Definition: offset32.h:63
Player
Definition: basic_type.h:8
@ BLACK
Definition: basic_type.h:9
constexpr bool isLong(Direction d)
Definition: basic_type.h:350
static int count(const PieceVector &direct_pieces, const NumEffectState &state, Square target, Player attack)