Belofte  version 2.1.5
A promising chess program using the UCI or Winboard interface
san.h
Go to the documentation of this file.
1 /*---------------------------------------------------------------------+
2  * File: san.h
3  * Project: part of belofte - A Promising Chess Program
4  * Author: yves
5  * SPDX-License-Identifier: GPL-2.0-only
6 +----------------------------------------------------------------------*/
7 
8 #if !defined(SAN_H)
9 #define SAN_H
10 
11 /** PgnMove is for user-interface only */
12 class bPgnMove final {
13 public:
14  bPgnMove(bPgnMove const& m);
15  bPgnMove(bBoard const& b, bMove const& m);
16  bPgnMove(bBoard const& b, basicmove_t const bm);
17  bPgnMove(bBoard const& b, move_t const mt);
18  ~bPgnMove();
19 
20  // no copy or move ctor nor assignment defined
21  bPgnMove& operator=(bPgnMove const&) = delete;
22  bPgnMove(bPgnMove&&) = delete;
23  bPgnMove& operator=(bPgnMove&&) = delete;
24 
25 private:
26  void ctor(bBoard const& b, bMove const& m); /// embedded base constructor
27 
28 public:
29  operator std::string() const;
30  std::string getMoveEvalStr() const { return m_evalstr; }
31 
32 private:
33  friend bool operator==(bPgnMove const& lhs, std::string const& rhs);
34  friend std::ostream& operator<<(std::ostream& os, bPgnMove const& m);
35 
36 private:
37  std::string const getPromotionDecorationStr(ppiece_t const piece) const;
38 
39  std::string m_move;
40  std::string m_evalstr;
41 };
42 
43 //-----------------------------------------------------------------------
44 
45 class bPgnMoveList final {
46 public:
47  explicit bPgnMoveList(bBoard& b);
48  ~bPgnMoveList();
49 
50 private:
51  friend std::ostream& operator<<(std::ostream& os, bPgnMoveList const& mpl);
52 
53 private:
54  std::vector<bPgnMove> m_pmoves;
55 };
56 
57 //-----------------------------------------------------------------------
58 
59 /** simple coordmove, with 4 characters, or 5 characters in case of promotion
60  * mostly used for interface
61  */
62 class bCoordMove : public bBasicMove {
63 public:
64  explicit bCoordMove(std::string const& coordmove);
65  explicit bCoordMove(bBasicMove const& m);
66  ~bCoordMove() override {}
67 
68  operator std::string() const;
69 
70  friend bool operator==(bCoordMove const& lhs, bCoordMove const& rhs) {
71  return (lhs.from() == rhs.from())
72  && (lhs.to() == rhs.to())
73  && (lhs.getPromotion() == rhs.getPromotion());
74  }
75 
76 private:
77  void setPromotion(const cpiece_t p);
78 };
79 
80 #endif // defined SAN_H
81 
82 // eof
uint16_t basicmove_t
0-63 or 0xFF: representation 0b00111111 -> case bits
Definition: belofte.h:99
uint32_t move_t
moveflags: bitfield
Definition: belofte.h:101
move
Definition: move.h:91
MEMBER_CONSTEXPR case_t to() const
Definition: move.h:113
MEMBER_CONSTEXPR case_t from() const
Definition: move.h:109
MEMBER_CONSTEXPR ppiece_t getPromotion() const
Definition: move.h:128
board
Definition: board.h:111
simple coordmove, with 4 characters, or 5 characters in case of promotion mostly used for interface
Definition: san.h:62
~bCoordMove() override
Definition: san.h:66
bCoordMove(std::string const &coordmove)
Definition: san.cpp:10
friend bool operator==(bCoordMove const &lhs, bCoordMove const &rhs)
Definition: san.h:70
Definition: move.h:164
PgnMove is for user-interface only.
Definition: san.h:12
std::string getMoveEvalStr() const
Definition: san.h:30
friend std::ostream & operator<<(std::ostream &os, bPgnMove const &m)
Definition: san.cpp:198
bPgnMove(bPgnMove &&)=delete
friend bool operator==(bPgnMove const &lhs, std::string const &rhs)
Definition: san.cpp:193
bPgnMove & operator=(bPgnMove const &)=delete
bPgnMove & operator=(bPgnMove &&)=delete
~bPgnMove()
Definition: san.cpp:168
bPgnMove(bPgnMove const &m)
Definition: san.cpp:70
friend std::ostream & operator<<(std::ostream &os, bPgnMoveList const &mpl)
Definition: san.cpp:221
~bPgnMoveList()
Definition: san.cpp:216
bPgnMoveList(bBoard &b)
Definition: san.cpp:206
enum tCPiece cpiece_t
Definition: piece.h:35
uint16_t ppiece_t
Definition: piece.h:46