My Project
pawnCheckmateMoves.h
Go to the documentation of this file.
1 /* pawnCheckmateMoves.h
2  */
3 #ifndef _PAWNCHECKMATEMOVES_H
4 #define _PAWNCHECKMATEMOVES_H
5 
6 #include "osl/basic_type.h"
7 namespace osl
8 {
9  namespace checkmate
10  {
12  {
17  template <Player P>
18  static bool effectiveOnlyIfPawnCheckmate(Ptype ptype,
19  Square from, Square to)
20  {
21  return ((ptype == PAWN) || (ptype == ROOK) || (ptype == BISHOP))
22  && (from.canPromote<P>() || to.canPromote<P>());
23  }
24  static bool effectiveOnlyIfPawnCheckmate(Player a, Ptype ptype,
25  Square from, Square to)
26  {
27  return ((ptype == PAWN) || (ptype == ROOK) || (ptype == BISHOP))
28  && (from.canPromote(a) || to.canPromote(a));
29  }
31  {
33  m.from(), m.to());
34  }
35 
36  static bool hasParingNoPromote(bool isPromote, Ptype ptype)
37  {
38  return isPromote
39  && ((ptype == PPAWN) || (ptype == PROOK) || (ptype == PBISHOP));
40  }
45  static bool hasParingNoPromote(Move m)
46  {
47  return hasParingNoPromote(m.isPromotion(), m.ptype());
48  }
49  };
50  } // namespace checkmate
51 } // namespace osl
52 
53 #endif /* _PAWNCHECKMATEMOVES_H */
54 // ;;; Local Variables:
55 // ;;; mode:c++
56 // ;;; c-basic-offset:2
57 // ;;; End:
osl::Square
Definition: basic_type.h:532
osl::checkmate::PawnCheckmateMoves::hasParingNoPromote
static bool hasParingNoPromote(Move m)
m を不成にした指手は打歩詰の時以外は試さなくて良い.
Definition: pawnCheckmateMoves.h:45
osl::Move
圧縮していない moveの表現 .
Definition: basic_type.h:1052
basic_type.h
osl::checkmate::PawnCheckmateMoves::hasParingNoPromote
static bool hasParingNoPromote(bool isPromote, Ptype ptype)
Definition: pawnCheckmateMoves.h:36
osl::Ptype
Ptype
駒の種類を4ビットでコード化する
Definition: basic_type.h:84
checkmate
osl::BISHOP
@ BISHOP
Definition: basic_type.h:99
osl::PAWN
@ PAWN
Definition: basic_type.h:95
osl::PPAWN
@ PPAWN
Definition: basic_type.h:87
osl::PBISHOP
@ PBISHOP
Definition: basic_type.h:91
osl::Move::from
const Square from() const
Definition: basic_type.h:1125
osl::ROOK
@ ROOK
Definition: basic_type.h:100
osl::Square::canPromote
bool canPromote() const
Definition: basic_type.h:659
osl::Move::ptype
Ptype ptype() const
Definition: basic_type.h:1155
osl::checkmate::PawnCheckmateMoves
Definition: pawnCheckmateMoves.h:12
osl::PROOK
@ PROOK
Definition: basic_type.h:92
osl::checkmate::PawnCheckmateMoves::effectiveOnlyIfPawnCheckmate
static bool effectiveOnlyIfPawnCheckmate(Player a, Ptype ptype, Square from, Square to)
Definition: pawnCheckmateMoves.h:24
osl::Player
Player
Definition: basic_type.h:8
osl::Move::to
const Square to() const
Definition: basic_type.h:1132
osl::checkmate::PawnCheckmateMoves::effectiveOnlyIfPawnCheckmate
static bool effectiveOnlyIfPawnCheckmate(Ptype ptype, Square from, Square to)
指手は打歩詰の時以外は試さなくて良い TODO: 敵陣2段目の香も打歩詰以外は成るべき
Definition: pawnCheckmateMoves.h:18
osl::Move::isPromotion
bool isPromotion() const
Definition: basic_type.h:1147
osl::Move::player
Player player() const
Definition: basic_type.h:1195
osl
Definition: additionalEffect.h:6
osl::checkmate::PawnCheckmateMoves::effectiveOnlyIfPawnCheckmate
static bool effectiveOnlyIfPawnCheckmate(Move m)
Definition: pawnCheckmateMoves.h:30