-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rename Ply to Move (remove old Move), Board fmt
- Loading branch information
1 parent
9c35073
commit 16b7335
Showing
12 changed files
with
172 additions
and
163 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,6 @@ | |
#include "constants.h" | ||
#include "move.h" | ||
#include "piece.h" | ||
#include "ply.h" | ||
#include "square.h" | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,35 @@ | ||
#include "move.h" | ||
|
||
namespace chess { | ||
Move::Move() {} | ||
|
||
Move::Move(Ply& white, Ply& black) { | ||
ply_[piece::white] = white; | ||
ply_[piece::black] = black; | ||
Move::Move(Piece& piece, move::type type, square::name from, square::name to) | ||
: piece_(piece) { | ||
type_ = type; | ||
from_ = from; | ||
to_ = to; | ||
} | ||
|
||
void Move::ply(piece::color color, Ply& ply) { ply_[color] = ply; } | ||
const move::type Move::type() const { return type_; } | ||
|
||
const piece::color Move::color() const { return piece_.color(); } | ||
|
||
const piece::type Move::piece_type() const { return piece_.type(); } | ||
|
||
const Piece& Move::piece() const { return piece_; } | ||
|
||
const square::name Move::from() const { return from_; } | ||
|
||
void Move::from(square::name square) { from_ = square; } | ||
|
||
const Ply& Move::ply(piece::color color) const { return ply_[color].value(); } | ||
const square::name Move::to() const { return to_; } | ||
|
||
void Move::to(square::name square) { to_ = square; } | ||
|
||
const bool Move::promotion() const { return (type_ & 0b1000) >> 3; } | ||
|
||
const bool Move::capture() const { return (type_ & 0b0100) >> 2; } | ||
|
||
Move& Move::operator=(Move& move) { | ||
*this = move; | ||
return *this; | ||
} | ||
} // namespace chess |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,81 @@ | ||
#ifndef CHESSPP_MOVE_H | ||
#define CHESSPP_MOVE_H | ||
|
||
#include <array> | ||
#include <optional> | ||
#include <string_view> | ||
|
||
#include "constants.h" | ||
#include "ply.h" | ||
#include "piece.h" | ||
|
||
/**API Example | ||
* Move move; | ||
* Move move(ply_w, ply_b); | ||
* | ||
* Get particular ply | ||
* move.ply(piece::white); | ||
* | ||
* Set particular ply | ||
* move.ply(piece::black, ply); | ||
* Move move(e_pawn, move::double_pawn_push, square::E2, square::E4); | ||
* | ||
* // Get move type | ||
* move.type(); | ||
* | ||
* // Get player color | ||
* move.color(); | ||
* | ||
* // Get piece type | ||
* move.piece_type(); | ||
* | ||
* // Get piece object (const ref) | ||
* move.piece() | ||
* | ||
* // Starting square | ||
* move.from(); | ||
* move.from(E2); | ||
* | ||
* // Ending square | ||
* move.to(); | ||
* move.to(E4); | ||
* | ||
* // Check if promotion | ||
* move.promotion(); | ||
* | ||
* // Check if capture | ||
* move.capture(); | ||
*/ | ||
|
||
namespace chess { | ||
class Move { | ||
public: | ||
Move(); | ||
Move(Ply& white, Ply& black); | ||
Move(Piece& piece, move::type type, square::name from, square::name to); | ||
|
||
const move::type type() const; | ||
|
||
void ply(piece::color color, Ply& ply); | ||
const Ply& ply(piece::color color) const; | ||
const piece::color color() const; | ||
|
||
const piece::type piece_type() const; | ||
|
||
const Piece& piece() const; | ||
|
||
const square::name from() const; | ||
void from(square::name square); | ||
|
||
const square::name to() const; | ||
void to(square::name square); | ||
|
||
const bool promotion() const; | ||
const bool capture() const; | ||
|
||
Move& operator=(Move& move); | ||
|
||
private: | ||
std::array<types::PlyOptional, 2> ply_; | ||
const Piece& piece_; | ||
move::type type_; | ||
square::name from_; | ||
square::name to_; | ||
}; | ||
} // namespace chess | ||
|
||
namespace chess::types { | ||
using MoveOptional = std::optional<Move>; | ||
using nullmove = std::nullopt_t; | ||
} // namespace chess::types | ||
|
||
namespace chess { | ||
constexpr types::MoveOptional nullmove = std::nullopt; | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.