Skip to content

Commit

Permalink
Clean up some constants.
Browse files Browse the repository at this point in the history
* Remove unused 'BIG' constant.
* Capture "N/A" vertex value in constant.

Pull request leela-zero#1528.
  • Loading branch information
TFiFiE authored and gcp committed Jun 11, 2018
1 parent d362ee8 commit 06759c1
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 14 deletions.
4 changes: 3 additions & 1 deletion src/FastBoard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ using namespace Utils;

const int FastBoard::NBR_SHIFT;
const int FastBoard::MAXSQ;
const int FastBoard::BIG;
const int FastBoard::NO_VERTEX;
const int FastBoard::PASS;
const int FastBoard::RESIGN;

Expand Down Expand Up @@ -146,6 +146,8 @@ void FastBoard::reset_board(int size) {
m_parent[MAXSQ] = MAXSQ;
m_libs[MAXSQ] = 16384; /* we will subtract from this */
m_next[MAXSQ] = MAXSQ;

assert(m_square[NO_VERTEX] == INVAL);
}

bool FastBoard::is_suicide(int i, int color) const {
Expand Down
5 changes: 2 additions & 3 deletions src/FastBoard.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,9 @@ class FastBoard {
static constexpr int MAXSQ = ((BOARD_SIZE + 2) * (BOARD_SIZE + 2));

/*
infinite score
no applicable vertex
*/
static constexpr int BIG = 10000000;

static constexpr int NO_VERTEX = 0;
/*
vertex of a pass
*/
Expand Down
10 changes: 5 additions & 5 deletions src/FastState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ void FastState::init_game(int size, float komi) {

m_movenum = 0;

m_komove = 0;
m_lastmove = 0;
m_komove = FastBoard::NO_VERTEX;
m_lastmove = FastBoard::NO_VERTEX;
m_komi = komi;
m_handicap = 0;
m_passes = 0;
Expand All @@ -53,8 +53,8 @@ void FastState::reset_game(void) {
m_movenum = 0;
m_passes = 0;
m_handicap = 0;
m_komove = 0;
m_lastmove = 0;
m_komove = FastBoard::NO_VERTEX;
m_lastmove = FastBoard::NO_VERTEX;
}

void FastState::reset_board(void) {
Expand All @@ -77,7 +77,7 @@ void FastState::play_move(int color, int vertex) {
board.m_hash ^= Zobrist::zobrist_ko[m_komove];
if (vertex == FastBoard::PASS) {
// No Ko move
m_komove = 0;
m_komove = FastBoard::NO_VERTEX;
} else {
m_komove = board.update_board(color, vertex);
}
Expand Down
6 changes: 3 additions & 3 deletions src/FullBoard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ std::uint64_t FullBoard::calc_hash(int komove) const {

std::uint64_t FullBoard::calc_symmetry_hash(int komove, int symmetry) const {
return calc_hash(komove, [this, symmetry](const auto vertex) {
if (vertex == 0) {
return 0;
if (vertex == NO_VERTEX) {
return NO_VERTEX;
} else {
const auto newvtx = Network::get_symmetry(get_xy(vertex), symmetry, m_boardsize);
return get_vertex(newvtx.first, newvtx.second);
Expand Down Expand Up @@ -193,7 +193,7 @@ int FullBoard::update_board(const int color, const int i) {
}

// No ko
return 0;
return NO_VERTEX;
}

void FullBoard::display_board(int lastmove) {
Expand Down
4 changes: 2 additions & 2 deletions src/FullBoard.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ class FullBoard : public FastBoard {
void reset_board(int size);
void display_board(int lastmove = -1);

std::uint64_t calc_hash(int komove = 0) const;
std::uint64_t calc_symmetry_hash(int komove = 0, int symmetry = 0) const;
std::uint64_t calc_hash(int komove = NO_VERTEX) const;
std::uint64_t calc_symmetry_hash(int komove = NO_VERTEX, int symmetry = 0) const;
std::uint64_t calc_ko_hash() const;

std::uint64_t m_hash;
Expand Down

0 comments on commit 06759c1

Please sign in to comment.