From d7852a23ae0f2785bb83ab162984663dc41fed8f Mon Sep 17 00:00:00 2001 From: Vincent Ollivier Date: Mon, 16 Apr 2012 09:07:13 +0200 Subject: [PATCH] Remove 'get_' from Piece and Move getters --- src/attack.cpp | 10 ++++----- src/board.h | 2 +- src/game.h | 2 +- src/move.cpp | 18 ++++++++-------- src/move.h | 42 ++++++++++++++++++------------------ src/movegen.cpp | 56 ++++++++++++++++++++++++------------------------ src/moves.cpp | 6 +++--- src/output.cpp | 18 ++++++++-------- src/piece.cpp | 4 ++-- src/piece.h | 6 +++--- src/pieces.h | 4 ++-- src/protocol.cpp | 4 ++-- src/search.cpp | 8 +++---- test/unit/test_move.cpp | 36 +++++++++++++++---------------- test/unit/test_moves.cpp | 14 ++++++------ test/unit/test_piece.cpp | 6 +++--- 16 files changed, 118 insertions(+), 118 deletions(-) diff --git a/src/attack.cpp b/src/attack.cpp index 84bc430..940eca7 100644 --- a/src/attack.cpp +++ b/src/attack.cpp @@ -41,8 +41,8 @@ bool Board::is_attacked_by(Color c, Square s, const Pieces& pieces) const // Specific code for pawns for (int i = 0; i < 2; ++i) { Square from = Square(s + PAWN_CAPTURE_DIRS[!c][i]); - if (get_piece(from).get_type() == PAWN && - get_piece(from).get_color() == c) { + if (get_piece(from).type() == PAWN && + get_piece(from).color() == c) { return true; } } @@ -57,12 +57,12 @@ bool Board::is_attacked_by(Color c, Square s, const Pieces& pieces) const */ bool Board::can_go(Piece p, Square from, Square to) const { - PieceType t = p.get_type(); - Color c = p.get_color(); + PieceType t = p.type(); + Color c = p.color(); Direction d = get_direction_to(from, to); // A piece cannot capture another piece of the same color - if (!is_empty(to) && get_piece(to).get_color() == c) return false; + if (!is_empty(to) && get_piece(to).color() == c) return false; Direction push_dir; Square s; diff --git a/src/board.h b/src/board.h index c574869..39443a1 100644 --- a/src/board.h +++ b/src/board.h @@ -41,7 +41,7 @@ class Board board[s] = p; }; bool is_empty(Square s) const { - return board[s].get_type() == EMPTY; + return board[s].type() == EMPTY; }; static bool is_out(Square s) { return s & 0x88; diff --git a/src/game.h b/src/game.h index 0ed748d..12ecd3a 100644 --- a/src/game.h +++ b/src/game.h @@ -51,7 +51,7 @@ class Game void add_piece(Color c, PieceType t, Square s); void del_piece(Color c, PieceType t, int i); void del_piece(Piece p) { - del_piece(p.get_color(), p.get_type(), p.get_index()); + del_piece(p.color(), p.type(), p.index()); }; void new_position(); diff --git a/src/move.cpp b/src/move.cpp index ec9b1d7..d1e3fde 100644 --- a/src/move.cpp +++ b/src/move.cpp @@ -20,9 +20,9 @@ #include "move.h" #include "piece.h" -PieceType Move::get_promotion_type() const +PieceType Move::promotion_type() const { - switch (get_type()) { + switch (type()) { case KNIGHT_PROMOTION: case KNIGHT_PROMOTION_CAPTURE: return KNIGHT; @@ -40,9 +40,9 @@ PieceType Move::get_promotion_type() const } } -PieceType Move::get_castle_side() const +PieceType Move::castle_side() const { - switch (get_type()) { + switch (type()) { case KING_CASTLE: return KING; case QUEEN_CASTLE: return QUEEN; default: return EMPTY; @@ -58,12 +58,12 @@ std::string Move::to_string() const { if (is_null()) return "#"; std::string res = ""; - res += static_cast('a' + get_orig_file()); - res += static_cast('1' + get_orig_rank()); - res += static_cast('a' + get_dest_file()); - res += static_cast('1' + get_dest_rank()); + res += static_cast('a' + orig_file()); + res += static_cast('1' + orig_rank()); + res += static_cast('a' + dest_file()); + res += static_cast('1' + dest_rank()); if (is_promotion()) { - res += Piece(BLACK, get_promotion_type()).to_string(); // Lower case + res += Piece(BLACK, promotion_type()).to_string(); // Lower case } return res; } diff --git a/src/move.h b/src/move.h index c337743..5b8f339 100644 --- a/src/move.h +++ b/src/move.h @@ -62,25 +62,25 @@ class Move t; }; - File get_orig_file() const { + File orig_file() const { return File((code >> OF_SHIFT) & OF_MASK); }; - Rank get_orig_rank() const { + Rank orig_rank() const { return Rank((code >> OR_SHIFT) & OR_MASK); }; - File get_dest_file() const { + File dest_file() const { return File((code >> DF_SHIFT) & DF_MASK); }; - Rank get_dest_rank() const { + Rank dest_rank() const { return Rank((code >> DR_SHIFT) & DR_MASK); }; - Square get_orig() const { - return Square(16 * get_orig_rank() + get_orig_file()); + Square orig() const { + return Square(16 * orig_rank() + orig_file()); }; - Square get_dest() const { - return Square(16 * get_dest_rank() + get_dest_file()); + Square dest() const { + return Square(16 * dest_rank() + dest_file()); }; - MoveType get_type() const { + MoveType type() const { return static_cast((code >> MT_SHIFT) & MT_MASK); }; @@ -94,16 +94,16 @@ class Move return is_set(3); }; bool is_double_pawn_push() const { - return get_type() == DOUBLE_PAWN_PUSH; + return type() == DOUBLE_PAWN_PUSH; }; bool is_en_passant() const { - return get_type() == EN_PASSANT; + return type() == EN_PASSANT; }; bool is_null() const { - return get_type() == NULL_MOVE; + return type() == NULL_MOVE; }; - PieceType get_promotion_type() const; - PieceType get_castle_side() const; + PieceType promotion_type() const; + PieceType castle_side() const; /* // Static member function for sorting move in natural order @@ -127,20 +127,20 @@ class Move class ExtendedMove : public Move { private: - char score; + char val; public: - ExtendedMove() : score(0) { code = NULL_MOVE; } - ExtendedMove(Move m, int s = 0) : score(s) { code = m.code; } + ExtendedMove() : val(0) { code = NULL_MOVE; } + ExtendedMove(Move m, int v = 0) : val(v) { code = m.code; } - char get_score() const { - return score; + char value() const { + return val; }; void set_score(int s) { - score = s; + val = s; }; bool operator<(const ExtendedMove& other) const { - return this->score > other.score; + return this->val > other.val; } }; diff --git a/src/movegen.cpp b/src/movegen.cpp index fddf117..9fcbcca 100644 --- a/src/movegen.cpp +++ b/src/movegen.cpp @@ -28,7 +28,7 @@ void Moves::generate_pieces(Color c, PieceType t, MoveType mt) Square to = Square(from + dirs[d]); while (!board.is_out(to)) { if (!board.is_empty(to)) { - if (board.get_piece(to).get_color() == c) break; + if (board.get_piece(to).color() == c) break; if (mt != QUIET_MOVE) { add(Move(from, to, CAPTURE)); } @@ -56,7 +56,7 @@ void Moves::generate(MoveType mt) if (mt == QUIET_MOVE) break; Square to = Square(from + PAWN_CAPTURE_DIRS[c][d]); if (board.is_out(to)) continue; - if (!board.is_empty(to) && board.get_piece(to).get_color() != c) { + if (!board.is_empty(to) && board.get_piece(to).color() != c) { if (board.is_pawn_end(c, to)) { // Promotion capture add(Move(from, to, KNIGHT_PROMOTION_CAPTURE)); add(Move(from, to, BISHOP_PROMOTION_CAPTURE)); @@ -109,8 +109,8 @@ void Moves::generate(MoveType mt) Square rook = Square(H1 + A8 * c); if (board.is_empty(Square(F1 + A8 * c)) && board.is_empty(to) && - board.get_piece(rook).get_type() == ROOK && - board.get_piece(rook).get_color() == c && + board.get_piece(rook).type() == ROOK && + board.get_piece(rook).color() == c && !board.is_attacked_by(!c, from, pieces) && !board.is_attacked_by(!c, to, pieces) && !board.is_attacked_by(!c, Square((F1 + A8 * c)), pieces) @@ -125,8 +125,8 @@ void Moves::generate(MoveType mt) if (board.is_empty(Square(B1 + A8 * c)) && board.is_empty(Square(D1 + A8 * c)) && board.is_empty(to) && - board.get_piece(rook).get_type() == ROOK && - board.get_piece(rook).get_color() == c && + board.get_piece(rook).type() == ROOK && + board.get_piece(rook).color() == c && !board.is_attacked_by(!c, from, pieces) && !board.is_attacked_by(!c, to, pieces) && !board.is_attacked_by(!c, Square((D1 + A8 * c)), pieces) @@ -138,12 +138,12 @@ void Moves::generate(MoveType mt) void Game::make_move(Move m) { - Square orig = m.get_orig(); - Square dest = m.get_dest(); + Square orig = m.orig(); + Square dest = m.dest(); Square ep = current_position().get_en_passant(); Color c = current_position().get_turn_color(); Piece p = board.get_piece(orig); - PieceType t = p.get_type(); + PieceType t = p.type(); Piece capture; assert(!board.is_out(orig)); assert(!board.is_out(dest)); @@ -186,7 +186,7 @@ void Game::make_move(Move m) assert(!board.is_empty(s) || assert_msg(debug_move(m))); capture = board.get_piece(s); - if (capture.get_type() == ROOK) { // Update opponent's castling rights + if (capture.type() == ROOK) { // Update opponent's castling rights if (dest == Square(H1 + A8 * !c)) { pos.set_castle_right(!c, KING, false); zobrist.update_castle_right(pos.hash(), !c, KING); @@ -202,7 +202,7 @@ void Game::make_move(Move m) // Castling if (m.is_castle()) { Square rook_orig, rook_dest; - switch (m.get_castle_side()) { + switch (m.castle_side()) { case KING: rook_orig = Square(H1 + A8 * c); rook_dest = Square(F1 + A8 * c); @@ -229,7 +229,7 @@ void Game::make_move(Move m) // Move the piece board.set_piece(Piece(), orig); // FIXME: duplicate in case of promotion? if (m.is_promotion()) { - add_piece(p.get_color(), m.get_promotion_type(), dest); + add_piece(p.color(), m.promotion_type(), dest); del_piece(p); } else { board.set_piece(p, dest); @@ -251,13 +251,13 @@ void Game::make_move(Move m) void Game::undo_move(Move m) { - Square orig = m.get_orig(); - Square dest = m.get_dest(); + Square orig = m.orig(); + Square dest = m.dest(); // Move back the piece to its origin Piece p = board.get_piece(dest); if (m.is_promotion()) { - add_piece(p.get_color(), PAWN, orig); + add_piece(p.color(), PAWN, orig); del_piece(p); } else if (!m.is_null()) { board.set_piece(p, orig); @@ -273,7 +273,7 @@ void Game::undo_move(Move m) s = (c == WHITE ? Square(dest + UP) : Square(dest + DOWN)); board.set_piece(Piece(), dest); } - add_piece(capture.get_color(), capture.get_type(), s); + add_piece(capture.color(), capture.type(), s); } else if (!m.is_null()) { board.set_piece(Piece(), dest); } @@ -282,7 +282,7 @@ void Game::undo_move(Move m) if (m.is_castle()) { Square rook_orig, rook_dest; Color c = current_position().get_turn_color(); - switch (m.get_castle_side()) { + switch (m.castle_side()) { case KING: rook_orig = Square(H1 + A8 * c); rook_dest = Square(F1 + A8 * c); @@ -312,15 +312,15 @@ bool Game::is_legal(Move m) // Null-move is obviously wrong if (m.is_null()) return false; - Square from = m.get_orig(); - Square to = m.get_dest(); + Square from = m.orig(); + Square to = m.dest(); // There must be a piece to move on the board if (board.is_empty(from)) return false; Piece p = board.get_piece(from); - PieceType t = p.get_type(); - Color c = p.get_color(); + PieceType t = p.type(); + Color c = p.color(); // The piece cannot be one of the opponent if (c != current_position().get_turn_color()) return false; @@ -353,22 +353,22 @@ bool Game::is_legal(Move m) // from another pawn, the later being captured by the former s = (c == BLACK ? Square(ep + UP) : Square(ep + DOWN)); - if (board.get_piece(s).get_type() != PAWN) return false; + if (board.get_piece(s).type() != PAWN) return false; } // An opponent's piece must be captured if (board.is_empty(s)) return false; - if (c == board.get_piece(s).get_color()) return false; + if (c == board.get_piece(s).color()) return false; } else if (m.is_castle()) { Square rook = Square(H1 + A8 * c); - switch (m.get_castle_side()) { + switch (m.castle_side()) { case KING: rook = Square(H1 + A8 * c); if (!board.is_empty(Square(F1 + A8 * c)) || !board.is_empty(to) || - board.get_piece(rook).get_type() != ROOK || - board.get_piece(rook).get_color() != c || + board.get_piece(rook).type() != ROOK || + board.get_piece(rook).color() != c || board.is_attacked_by(!c, from, pieces) || board.is_attacked_by(!c, Square((F1 + A8 * c)), pieces) || board.is_attacked_by(!c, to, pieces)) { @@ -380,8 +380,8 @@ bool Game::is_legal(Move m) if (!board.is_empty(Square(B1 + A8 * c)) || !board.is_empty(Square(D1 + A8 * c)) || !board.is_empty(to) || - board.get_piece(rook).get_type() != ROOK || - board.get_piece(rook).get_color() != c || + board.get_piece(rook).type() != ROOK || + board.get_piece(rook).color() != c || board.is_attacked_by(!c, from, pieces) || board.is_attacked_by(!c, Square((D1 + A8 * c)), pieces) || board.is_attacked_by(!c, to, pieces)) { diff --git a/src/moves.cpp b/src/moves.cpp index 9496643..1ed0ae7 100644 --- a/src/moves.cpp +++ b/src/moves.cpp @@ -75,7 +75,7 @@ ExtendedMove Moves::next() // Find the best remaining capture by selection sort auto max = i; for (auto j = i + 1; j < n; ++j) { - if (moves[j].get_score() > moves[max].get_score()) { + if (moves[j].value() > moves[max].value()) { max = j; } } @@ -162,8 +162,8 @@ void Moves::init_mvv_lva_scores() Score Moves::get_mvv_lva_score(Move move) { assert(move.is_capture()); - PieceType a = board.get_piece(move.get_orig()).get_type(); - PieceType v = board.get_piece(move.get_dest()).get_type(); + PieceType a = board.get_piece(move.orig()).type(); + PieceType v = board.get_piece(move.dest()).type(); if (move.is_en_passant()) return mvv_lva_scores[PAWN][a]; return mvv_lva_scores[v][a]; } diff --git a/src/output.cpp b/src/output.cpp index c1a9ced..75983ac 100644 --- a/src/output.cpp +++ b/src/output.cpp @@ -96,20 +96,20 @@ std::string Game::output_move(Move m) // Castling if (m.is_castle()) { - if (m.get_castle_side() == QUEEN) stream << "O-"; + if (m.castle_side() == QUEEN) stream << "O-"; return stream.str() + "O-O"; } // Type of piece - Square from = m.get_orig(); + Square from = m.orig(); Piece p = board.get_piece(from); - PieceType t = p.get_type(); + PieceType t = p.type(); if (t > PAWN) stream << Piece(WHITE, t); // Upper case // Disambiguation if (t != PAWN) { - Color c = p.get_color(); - Square to = m.get_dest(); + Color c = p.color(); + Square to = m.dest(); for (int i = 0; i < pieces.count(c, t); ++i) { Piece other(c, t, i); if (other == p) continue; @@ -119,7 +119,7 @@ std::string Game::output_move(Move m) // attack the destination (fast answer by array lookup) // and can really go to this destination (not so fast // answer) then a disambiguation is needed - stream << static_cast('a' + m.get_orig_file()); + stream << static_cast('a' + m.orig_file()); break; } } @@ -127,16 +127,16 @@ std::string Game::output_move(Move m) // Capture if (m.is_capture()) { - if (t == PAWN) stream << static_cast('a' + m.get_orig_file()); + if (t == PAWN) stream << static_cast('a' + m.orig_file()); stream << "x"; } // Destination - stream << output_square(m.get_dest_file(), m.get_dest_rank()); + stream << output_square(m.dest_file(), m.dest_rank()); // Promotion if (m.is_promotion()) { - stream << "=" << Piece(WHITE, m.get_promotion_type()); + stream << "=" << Piece(WHITE, m.promotion_type()); } return stream.str(); diff --git a/src/piece.cpp b/src/piece.cpp index 60e29c4..907d5c6 100644 --- a/src/piece.cpp +++ b/src/piece.cpp @@ -26,7 +26,7 @@ std::ostream& operator<<(std::ostream& out, const Piece piece) std::string Piece::to_string() const { char t; - switch (get_type()) { + switch (type()) { case PAWN: t = 'P'; break; case KNIGHT: t = 'N'; break; case BISHOP: t = 'B'; break; @@ -35,7 +35,7 @@ std::string Piece::to_string() const case KING: t = 'K'; break; default: t = ' '; break; } - if (get_color() == BLACK) { + if (color() == BLACK) { t = static_cast(t + 'a' - 'A'); // Lower case for black pieces } return std::string(1, t); diff --git a/src/piece.h b/src/piece.h index 8384770..9915a93 100644 --- a/src/piece.h +++ b/src/piece.h @@ -51,13 +51,13 @@ class Piece (static_cast(c) << C_SHIFT); } - Color get_color() const { + Color color() const { return static_cast((code >> C_SHIFT) & C_MASK); }; - PieceType get_type() const { + PieceType type() const { return static_cast((code >> T_SHIFT) & T_MASK); }; - int get_index() const { + int index() const { return (code >> I_SHIFT) & I_MASK; }; /* diff --git a/src/pieces.h b/src/pieces.h index 837e6e1..6a6874f 100644 --- a/src/pieces.h +++ b/src/pieces.h @@ -32,14 +32,14 @@ class Pieces public: Pieces(); Square get_position(Piece p) const { - return positions[p.get_color()][p.get_type()][p.get_index()]; + return positions[p.color()][p.type()][p.index()]; }; Square get_position(Color c, PieceType t, int i) const { assert(0 <= i && i < 9); return positions[c][t][i]; }; void set_position(Piece p, Square s) { - positions[p.get_color()][p.get_type()][p.get_index()] = s; + positions[p.color()][p.type()][p.index()] = s; }; void set_position(Color c, PieceType t, int i, Square s) { assert(0 <= i && i < 9); diff --git a/src/protocol.cpp b/src/protocol.cpp index cd4f3f5..5668cac 100644 --- a/src/protocol.cpp +++ b/src/protocol.cpp @@ -75,7 +75,7 @@ Move Protocol::parse_move(std::string move) default: return Move(); } } - if (game.board.get_piece(from).get_type() == PAWN) { + if (game.board.get_piece(from).type() == PAWN) { if (game.board.is_pawn_begin(c, from) && to == Square(from + 2 * PAWN_PUSH_DIRS[c])) { return Move(from, to, DOUBLE_PAWN_PUSH); @@ -84,7 +84,7 @@ Move Protocol::parse_move(std::string move) return Move(from, to, EN_PASSANT); } } - if (game.board.get_piece(from).get_type() == KING) { + if (game.board.get_piece(from).type() == KING) { if (to == Square(from + RIGHT + RIGHT)) { return Move(from, to, KING_CASTLE); } else if (to == Square(from + LEFT + LEFT)) { diff --git a/src/search.cpp b/src/search.cpp index ed4dee8..844357a 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -29,15 +29,15 @@ inline bool Game::is_dangerous(Move m) // current_position() is used assuming // that the move as already been made. - if (board.get_piece(m.get_dest()).get_type() == PAWN) { + if (board.get_piece(m.dest()).type() == PAWN) { const Color c = !current_position().get_turn_color(); - if (m.get_dest_rank() + RANK_6 * c == RANK_7) return true; + if (m.dest_rank() + RANK_6 * c == RANK_7) return true; } /* if (m.is_capture()) { const Piece capture = current_position().get_capture(); - if (capture.get_type() != PAWN) return true; + if (capture.type() != PAWN) return true; } return m.is_promotion(); @@ -215,7 +215,7 @@ int Game::search(int alpha, int beta, int depth, const int ply) Move move; while (!(move = moves.next()).is_null()) { if (move.is_capture()) { - if (board.get_piece(move.get_dest()).get_type() == KING) { + if (board.get_piece(move.dest()).type() == KING) { return INF - ply; // Checkmate } } diff --git a/test/unit/test_move.cpp b/test/unit/test_move.cpp index d28c669..33fbdb3 100644 --- a/test/unit/test_move.cpp +++ b/test/unit/test_move.cpp @@ -70,14 +70,14 @@ TEST(MoveTest, Constructor) if (d == OUT || d == o) continue; for (const MoveType &t : MOVES) { Move m(o, d, t); - EXPECT_EQ(o, m.get_orig()); - EXPECT_EQ(d, m.get_dest()); - EXPECT_EQ(t, m.get_type()); + EXPECT_EQ(o, m.orig()); + EXPECT_EQ(d, m.dest()); + EXPECT_EQ(t, m.type()); - EXPECT_EQ(Board::get_file(o), m.get_orig_file()); - EXPECT_EQ(Board::get_file(d), m.get_dest_file()); - EXPECT_EQ(Board::get_rank(o), m.get_orig_rank()); - EXPECT_EQ(Board::get_rank(d), m.get_dest_rank()); + EXPECT_EQ(Board::get_file(o), m.orig_file()); + EXPECT_EQ(Board::get_file(d), m.dest_file()); + EXPECT_EQ(Board::get_rank(o), m.orig_rank()); + EXPECT_EQ(Board::get_rank(d), m.dest_rank()); /* // FIXME: Takes too long, too much moves @@ -128,26 +128,26 @@ TEST(MoveTest, Type) switch (t) { case KING_CASTLE: - EXPECT_EQ(KING, m.get_castle_side()); + EXPECT_EQ(KING, m.castle_side()); break; case QUEEN_CASTLE: - EXPECT_EQ(QUEEN, m.get_castle_side()); + EXPECT_EQ(QUEEN, m.castle_side()); break; case KNIGHT_PROMOTION: case KNIGHT_PROMOTION_CAPTURE: - EXPECT_EQ(KNIGHT, m.get_promotion_type()); + EXPECT_EQ(KNIGHT, m.promotion_type()); break; case BISHOP_PROMOTION: case BISHOP_PROMOTION_CAPTURE: - EXPECT_EQ(BISHOP, m.get_promotion_type()); + EXPECT_EQ(BISHOP, m.promotion_type()); break; case ROOK_PROMOTION: case ROOK_PROMOTION_CAPTURE: - EXPECT_EQ(ROOK, m.get_promotion_type()); + EXPECT_EQ(ROOK, m.promotion_type()); break; case QUEEN_PROMOTION: case QUEEN_PROMOTION_CAPTURE: - EXPECT_EQ(QUEEN, m.get_promotion_type()); + EXPECT_EQ(QUEEN, m.promotion_type()); break; default: break; @@ -168,7 +168,7 @@ TEST(ExtendedMoveTest, Size) TEST(ExtendedMoveTest, Constructor) { EXPECT_EQ(Move(), ExtendedMove()); - EXPECT_EQ(0, ExtendedMove().get_score()); + EXPECT_EQ(0, ExtendedMove().value()); for (const Square &o : SQUARES) { if (o == OUT) continue; @@ -194,15 +194,15 @@ TEST(ExtendedMoveTest, Score) Move m; for (int i = SCHAR_MIN; i <= SCHAR_MAX; ++i) { ExtendedMove em1(m, i); - EXPECT_EQ(i, em1.get_score()); + EXPECT_EQ(i, em1.value()); // Test getter and setter ExtendedMove em2(m, 0); - EXPECT_EQ(0, em2.get_score()); + EXPECT_EQ(0, em2.value()); em2.set_score(i); - EXPECT_EQ(i, em2.get_score()); + EXPECT_EQ(i, em2.value()); em2.set_score(0); - EXPECT_EQ(0, em2.get_score()); + EXPECT_EQ(0, em2.value()); } } diff --git a/test/unit/test_moves.cpp b/test/unit/test_moves.cpp index 23ffa07..c02e2e6 100644 --- a/test/unit/test_moves.cpp +++ b/test/unit/test_moves.cpp @@ -25,7 +25,7 @@ TEST(MoveListTest, Constructor) EXPECT_TRUE(moves[j].is_null()); // Test default score - EXPECT_EQ(0, moves[j].get_score()); + EXPECT_EQ(0, moves[j].value()); } moves.inc_ply(); } @@ -40,7 +40,7 @@ TEST(MoveListTest, Assignement) ExtendedMove em1(m, i + j); moves[j] = em1; EXPECT_EQ(em1, moves[j]); - EXPECT_EQ(em1.get_score(), moves[j].get_score()); + EXPECT_EQ(em1.value(), moves[j].value()); } moves.inc_ply(); } @@ -49,7 +49,7 @@ TEST(MoveListTest, Assignement) for (int j = 0; j < MAX_BF; ++j) { ExtendedMove em1(m, i + j); EXPECT_EQ(em1, moves[j]); - EXPECT_EQ(em1.get_score(), moves[j].get_score()); + EXPECT_EQ(em1.value(), moves[j].value()); } } moves.clear(); @@ -57,7 +57,7 @@ TEST(MoveListTest, Assignement) for (int j = 0; j < MAX_BF; ++j) { ExtendedMove em1(m, i + j); EXPECT_EQ(em1, moves[j]); - EXPECT_EQ(em1.get_score(), moves[j].get_score()); + EXPECT_EQ(em1.value(), moves[j].value()); } moves.inc_ply(); } @@ -90,7 +90,7 @@ TEST(MovesTest, Constructor) Move m; ExtendedMove em(m, 50); list[0] = em; - EXPECT_EQ(em.get_score(), list[0].get_score()); + EXPECT_EQ(em.value(), list[0].value()); Moves moves(board, pieces, position, list); @@ -98,8 +98,8 @@ TEST(MovesTest, Constructor) // Test if MoveList::inc_ply() has been implicitly called by Moves() for (int i = 0; i < MAX_PLY; ++i) { - EXPECT_EQ(0, list[i].get_score()); + EXPECT_EQ(0, list[i].value()); } list.dec_ply(); - EXPECT_EQ(em.get_score(), list[0].get_score()); + EXPECT_EQ(em.value(), list[0].value()); } diff --git a/test/unit/test_piece.cpp b/test/unit/test_piece.cpp index 3f2dc23..dce3c68 100644 --- a/test/unit/test_piece.cpp +++ b/test/unit/test_piece.cpp @@ -9,9 +9,9 @@ TEST(PieceTest, Constructor) Piece p(c, t, i); // Test getters - EXPECT_EQ(c, p.get_color()); - EXPECT_EQ(t, p.get_type()); - EXPECT_EQ(i, p.get_index()); + EXPECT_EQ(c, p.color()); + EXPECT_EQ(t, p.type()); + EXPECT_EQ(i, p.index()); // Test comparison operators for (const Color &c2 : COLORS) { -- 2.11.4.GIT