Skip to content

Commit

Permalink
Allow configuring default komi at compile-time.
Browse files Browse the repository at this point in the history
Pull request leela-zero#2257.
  • Loading branch information
apetresc authored and gcp committed Apr 2, 2019
1 parent 9beb22e commit f6c18ac
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/GTP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,7 @@ void GTP::execute(GameState & game, const std::string& xinput) {
} else if (command.find("komi") == 0) {
std::istringstream cmdstream(command);
std::string tmp;
float komi = 7.5f;
float komi = KOMI;
float old_komi = game.get_komi();

cmdstream >> tmp; // eat komi
Expand Down
3 changes: 1 addition & 2 deletions src/Leela.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -533,8 +533,7 @@ int main(int argc, char *argv[]) {
auto maingame = std::make_unique<GameState>();

/* set board limits */
auto komi = 7.5f;
maingame->init_game(BOARD_SIZE, komi);
maingame->init_game(BOARD_SIZE, KOMI);

if (cfg_benchmark) {
cfg_quiet = false;
Expand Down
2 changes: 1 addition & 1 deletion src/Network.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ float Network::benchmark_time(int centiseconds) {
std::atomic<int> runcount{0};

GameState state;
state.init_game(BOARD_SIZE, 7.5);
state.init_game(BOARD_SIZE, KOMI);

// As a sanity run, try one run with self check.
// Isn't enough to guarantee correctness but better than nothing,
Expand Down
6 changes: 3 additions & 3 deletions src/SGFTree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ void SGFTree::init_state() {
// Initialize with defaults.
// The SGF might be missing boardsize or komi
// which means we'll never initialize properly.
m_state.init_game(std::min(BOARD_SIZE, 19), 7.5f);
m_state.init_game(std::min(BOARD_SIZE, 19), KOMI);
}

const KoState * SGFTree::get_state(void) const {
Expand Down Expand Up @@ -152,8 +152,8 @@ void SGFTree::populate_states() {
int bsize;
strm >> bsize;
if (bsize == BOARD_SIZE) {
// Assume 7.5 komi if not specified
m_state.init_game(bsize, 7.5f);
// Assume default komi in config.h if not specified
m_state.init_game(bsize, KOMI);
valid_size = true;
} else {
throw std::runtime_error("Board size not supported.");
Expand Down
5 changes: 5 additions & 0 deletions src/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ static_assert(BOARD_SIZE % 2 == 1,
static constexpr auto NUM_INTERSECTIONS = BOARD_SIZE * BOARD_SIZE;
static constexpr auto POTENTIAL_MOVES = NUM_INTERSECTIONS + 1; // including pass

/*
* KOMI: Define the default komi to use when training.
*/
static constexpr auto KOMI = 7.5f;

/*
* Features
*
Expand Down

0 comments on commit f6c18ac

Please sign in to comment.