diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..861cc3d --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +.bench +CMakeCache.txt +CMakeFiles +Makefile +cmake_install.cmake +test.db* diff --git a/CMakeLists.txt b/CMakeLists.txt index 744f00d..981917d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -38,9 +38,10 @@ else() message("Could not find HPX. Configuring without HPX support.") endif() -set(EXTRA_LIBS pthread) +set(EXTRA_LIBS pthread sqlite3) -#find_package(Readline) +find_package(Readline) +find_package(SQLite3) if(READLINE_FOUND) message("Readline was found.") diff --git a/cmake/FindSQLite3.cmake b/cmake/FindSQLite3.cmake new file mode 100644 index 0000000..aa650e3 --- /dev/null +++ b/cmake/FindSQLite3.cmake @@ -0,0 +1,87 @@ +# - Try to find Sqlite3 +# Once done this will define +# +# SQLITE3_FOUND - system has Sqlite3 +# SQLITE3_INCLUDE_DIRS - the Sqlite3 include directory +# SQLITE3_LIBRARIES - Link these to use Sqlite3 +# SQLITE3_DEFINITIONS - Compiler switches required for using Sqlite3 +# +# Copyright (c) 2008 Andreas Schneider +# +# Redistribution and use is allowed according to the terms of the New +# BSD license. +# For details see the accompanying COPYING-CMAKE-SCRIPTS file. +# + + +if (SQLITE3_LIBRARIES AND SQLITE3_INCLUDE_DIRS) + # in cache already + set(SQLITE3_FOUND TRUE) +else (SQLITE3_LIBRARIES AND SQLITE3_INCLUDE_DIRS) + # use pkg-config to get the directories and then use these values + # in the FIND_PATH() and FIND_LIBRARY() calls + if (${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4) + include(UsePkgConfig) + pkgconfig(sqlite3 _SQLITE3_INCLUDEDIR _SQLITE3_LIBDIR _SQLITE3_LDFLAGS _SQLITE3_CFLAGS) + else (${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4) + find_package(PkgConfig) + if (PKG_CONFIG_FOUND) + pkg_check_modules(_SQLITE3 sqlite3) + endif (PKG_CONFIG_FOUND) + endif (${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4) + find_path(SQLITE3_INCLUDE_DIR + NAMES + sqlite3.h + PATHS + ${_SQLITE3_INCLUDEDIR} + /usr/include + /usr/local/include + /opt/local/include + /sw/include + ) + + find_library(SQLITE3_LIBRARY + NAMES + sqlite3 + PATHS + ${_SQLITE3_LIBDIR} + /usr/lib + /usr/local/lib + /opt/local/lib + /sw/lib + ) + + if (SQLITE3_LIBRARY) + set(SQLITE3_FOUND TRUE) + endif (SQLITE3_LIBRARY) + + set(SQLITE3_INCLUDE_DIRS + ${SQLITE3_INCLUDE_DIR} + ) + + if (SQLITE3_FOUND) + set(SQLITE3_LIBRARIES + ${SQLITE3_LIBRARIES} + ${SQLITE3_LIBRARY} + ) + endif (SQLITE3_FOUND) + + if (SQLITE3_INCLUDE_DIRS AND SQLITE3_LIBRARIES) + set(SQLITE3_FOUND TRUE) + endif (SQLITE3_INCLUDE_DIRS AND SQLITE3_LIBRARIES) + + if (SQLITE3_FOUND) + if (NOT Sqlite3_FIND_QUIETLY) + message(STATUS "Found Sqlite3: ${SQLITE3_LIBRARIES}") + endif (NOT Sqlite3_FIND_QUIETLY) + else (SQLITE3_FOUND) + if (Sqlite3_FIND_REQUIRED) + message(FATAL_ERROR "Could not find Sqlite3") + endif (Sqlite3_FIND_REQUIRED) + endif (SQLITE3_FOUND) + + # show the SQLITE3_INCLUDE_DIRS and SQLITE3_LIBRARIES variables only in the advanced view + mark_as_advanced(SQLITE3_INCLUDE_DIRS SQLITE3_LIBRARIES) + +endif (SQLITE3_LIBRARIES AND SQLITE3_INCLUDE_DIRS) + diff --git a/harness_helgrind.pl b/harness_helgrind.pl old mode 100644 new mode 100755 index 7939af0..ad8d8d5 --- a/harness_helgrind.pl +++ b/harness_helgrind.pl @@ -1,3 +1,4 @@ +#!/usr/bin/perl ################################################################################ ## Copyright (c) 2011 Steve Brandt and Philip LeBlanc ## diff --git a/harness_memcheck.pl b/harness_memcheck.pl old mode 100644 new mode 100755 index 04007ac..cbd19f5 --- a/harness_memcheck.pl +++ b/harness_memcheck.pl @@ -1,3 +1,4 @@ +#!/usr/bin/perl ################################################################################ ## Copyright (c) 2011 Steve Brandt and Philip LeBlanc ## diff --git a/harness_plain.pl b/harness_plain.pl old mode 100644 new mode 100755 index 0bef76f..ea1c419 --- a/harness_plain.pl +++ b/harness_plain.pl @@ -1,3 +1,4 @@ +#!/usr/bin/perl ################################################################################ ## Copyright (c) 2011 Steve Brandt and Philip LeBlanc ## @@ -95,7 +96,7 @@ for(my $ply=4;$ply<=6;$ply++) { for(my $b=1;$b<=4;$b++) { - for my $sm (("minimax","alphabeta","mtdf")) { + for my $sm (("alphabeta")) { # It takes too long for minimax above ply 4 # So I ran it once at 5 to verify the answer # and then introduced this next. @@ -132,6 +133,7 @@ $cmd="CHX_THREADS_PER_PROC=$threads $mem $chx < .bench|"; } print "cmd=$cmd\n"; + system("rm -f test.db"); open($fd,$cmd); my $ans = ""; my $score = $bad_score; diff --git a/headers/chess_move.hpp b/headers/chess_move.hpp index 16d18f5..ad7a475 100644 --- a/headers/chess_move.hpp +++ b/headers/chess_move.hpp @@ -9,6 +9,7 @@ #define CHESS_MOVE_HPP_C1BEDE43_B47B_4694_ACF4_F41143D72B97 #include +#include /* This is the basic description of a chess_move. promote is what piece to promote the pawn to, if the chess_move is a pawn promotion. bits is a bitfield that describes the chess_move, @@ -54,10 +55,10 @@ class chess_move { u = ((from & 0xFF) << 24) + ((to & 0xFF) << 16) + ((promote & 0xFF) << 8) + ((bits & 0xFF) << 0); } - uint8_t getFrom() { return from; } - uint8_t getTo() { return to; } - uint8_t getPromote() { return promote; } - uint8_t getBits() { return bits; } + uint8_t getFrom() const { return from; } + uint8_t getTo() const { return to; } + uint8_t getPromote() const { return promote; } + uint8_t getBits() const { return bits; } uint8_t getCapture() const { return (bits & 1) != 0; } @@ -95,6 +96,8 @@ class chess_move { ar & this->promote; ar & this->bits; } + std::string str() const; + std::string pgn() const; }; #endif diff --git a/headers/database.hpp b/headers/database.hpp new file mode 100644 index 0000000..c905210 --- /dev/null +++ b/headers/database.hpp @@ -0,0 +1,202 @@ +#ifndef DATABASE_H +#define DATABASE_H +#include +#include +#include "hash.hpp" +#include "node.hpp" +#include "data.hpp" +#include "defs.hpp" +#include "chess_move.hpp" +#include "sqlite3.h" +#include "main.hpp" + +using namespace std; + +class database { + public: + sqlite3 *db; + char *zErrMsg=0; + int rc; + + + database(){ + const char *sql; + rc = sqlite3_open("test.db", &db); + if( rc ){ + fprintf(stderr, "Can't open database: %s\n", sqlite3_errmsg(db)); + exit(0); + }else{ + fprintf(stderr, "Opened database successfully\n"); + } + /* Create SQL statement */ + sql = "CREATE TABLE MoveSet(" \ + "PLY INTEGER NOT NULL," \ + "BOARD TEXT NOT NULL,"\ + "HI NUMERIC(20) NOT NULL,"\ + "LO NUMERIC(20) NOT NULL,"\ + "HASH INTEGER NOT NULL,"\ + "PRIMARY KEY (PLY, BOARD));"; + //Execute SQL statement + rc = sqlite3_exec(db, sql, 0, 0, &zErrMsg); + if( rc != SQLITE_OK ){ + fprintf(stderr, "%s\n", zErrMsg); + sqlite3_free(zErrMsg); + }else{ + fprintf(stdout, "Table created successfully\n"); + } +// deleteAll(); + }; + +//destructor + ~database(){ + get_data(); + sqlite3_close(db); + cout<<"database closed. \n"; + } + + void deleteAll(){ + const char *sql; + std::ostringstream o; + o<<"delete from \"MoveSet\""; + std::string result = o.str(); + sql=result.c_str(); + rc = sqlite3_exec(db, sql, callback, 0, &zErrMsg); + if ( rc == SQLITE_OK) cout<<"MoveSet sucessfully reset"; + else{ cout<= to current depth, most importantly score greater than the current score + int get_data(){ + const char *data= "Callback function called"; + const char *sql= "SELECT * from MoveSet"; + rc= sqlite3_exec(db, sql, 0, (void*)data, &zErrMsg); + if (rc!= SQLITE_OK ){ + fprintf(stderr, "SQL error: %s\n", zErrMsg); + sqlite3_free(zErrMsg); + }else + fprintf(stdout, "Operation done sucessfully\n"); + return 0; + } + + bool get_database_value(const node_t& board, score_t& zlo, score_t& zhi){ + bool gotten = false; + const char *sql; + std::ostringstream current, out; + print_board(board, current, true); + std::string curr = current.str(); + out<< "SELECT LO, HI FROM MoveSet WHERE \"BOARD\"=\""< 0) { + for (int i=0; i<(nrow+1)*ncolumn;i++) + cout<<"azResult["<depth >= 0 && board_equals(board, z->board)){ + lower = z->lower; + upper = z->upper; + gotten = true + } else { + lower = bad_min_score; + upper = bad_max_score; + }*/ + return gotten; + } + + //callback used for select operation + static int callback(void *NotUsed, int argc, char **argv, char **azColName){ + int i; + std::ostringstream out; + char ** res = (char **) NotUsed; + //*res=NULL(sizeof(char *)); + // cout<& workq, const char *s); char *move_str(chess_move& m); -void print_board(const node_t& board, std::ostream& out); +void print_board(const node_t& board, std::ostream& out,bool trimmed=false); int print_result(std::vector& workq, node_t& board); void start_benchmark(std::string filename, int ply_level, int num_runs,bool parallel); int get_ms(); std::string get_log_name(); int chx_main(); #ifdef HPX_SUPPORT +extern database dbase; extern std::ofstream **streams; extern bool file_output_enabled; #endif diff --git a/headers/parallel.hpp b/headers/parallel.hpp index b4a9ff3..fc64cc6 100644 --- a/headers/parallel.hpp +++ b/headers/parallel.hpp @@ -40,3 +40,4 @@ struct ScopedLock { #endif #endif +//extern Mutex mutex; diff --git a/headers/pgn.hpp b/headers/pgn.hpp new file mode 100644 index 0000000..c40b07a --- /dev/null +++ b/headers/pgn.hpp @@ -0,0 +1,9 @@ +#ifndef CHESS_MOVE_H + +#include "chess_move.hpp" +#include "node.hpp" +#include "data.hpp" + +const void pgn_output(const node_t &board, const chess_move &move); + +#endif diff --git a/headers/search.hpp b/headers/search.hpp index 316fcff..9b5556c 100644 --- a/headers/search.hpp +++ b/headers/search.hpp @@ -38,7 +38,7 @@ int min(int a,int b); int max(int a,int b); void xboard(); -extern Mutex mutex; +extern Mutex cmutex; extern const int num_proc; struct safe_move { diff --git a/src/.gitignore b/src/.gitignore new file mode 100644 index 0000000..60e2163 --- /dev/null +++ b/src/.gitignore @@ -0,0 +1,4 @@ +CMakeFiles +Makefile +chx +cmake_install.make diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a7b3401..ee937e8 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -12,7 +12,9 @@ set(sources minimax.cpp log_board.cpp timer.cpp - alphabeta.cpp) + alphabeta.cpp + chess_move.cpp + pgn.cpp) if(HPX_FOUND) set(sources ${sources} diff --git a/src/alphabeta.cpp b/src/alphabeta.cpp index 9ee8a1a..837ba31 100644 --- a/src/alphabeta.cpp +++ b/src/alphabeta.cpp @@ -8,12 +8,16 @@ //#undef NDEBUG #include "parallel_support.hpp" +#include "database.hpp" +#include "main.hpp" #include "search.hpp" #include #include "parallel.hpp" #include "zkey.hpp" #include +database dbase; + void search_ab_pt(boost::shared_ptr info) { info->result = search_ab(info); @@ -86,8 +90,9 @@ score_t search_ab(boost::shared_ptr proc_info) score_t max_val = bad_min_score; - score_t zlo,zhi; - if(get_transposition_value(board,zlo,zhi)) { + score_t zlo = bad_min_score,zhi = bad_max_score; + //dbase.add_data(board,zlo,zhi); + if(dbase.get_database_value(board,zlo,zhi)) { if(zlo >= beta) { return zlo; } @@ -221,7 +226,7 @@ score_t search_ab(boost::shared_ptr proc_info) if (board.ply == 0) { assert(max_move != INVALID_MOVE); - ScopedLock s(mutex); + ScopedLock s(cmutex); move_to_make = max_move; } @@ -230,7 +235,9 @@ score_t search_ab(boost::shared_ptr proc_info) DECL_SCORE(z,0,board.hash); return z; } - + dbase.add_data(board, + max(zlo,max_val >= beta ? max_val : bad_min_score), + min(zhi,max_val < alpha ? max_val : bad_max_score)); set_transposition_value(board, max(zlo,max_val >= beta ? max_val : bad_min_score), min(zhi,max_val < alpha ? max_val : bad_max_score)); diff --git a/src/chess_move.cpp b/src/chess_move.cpp new file mode 100644 index 0000000..83f545c --- /dev/null +++ b/src/chess_move.cpp @@ -0,0 +1,55 @@ +#include +#include "defs.hpp" +#include "data.hpp" +#include "chess_move.hpp" + +using namespace std; + +string chess_move::str() const +{ + ostringstream ostr; + ostr << (char)('a' + COL(getFrom())) << 8 - ROW(getFrom()) << + (char)('a' + COL(getTo())) << 8 - ROW(getTo()); + if (getBits() & 32) + switch (getPromote()) + { + case KNIGHT: + ostr << "n"; + break; + case BISHOP: + ostr << "b"; + break; + case ROOK: + ostr << "r"; + break; + default: + ostr << "q"; + break; + } + return ostr.str(); +} +string chess_move::pgn() const +{ + ostringstream ostr; + ostr << piece_char[getFrom()]; + ostr << (char)('a' + COL(getFrom())) << 8 - ROW(getFrom()) << + (char)('a' + COL(getTo())) << 8 - ROW(getTo()); + if (getBits() & 32) + switch (getPromote()) + { + case KNIGHT: + ostr << "=N"; + break; + case BISHOP: + ostr << "=B"; + break; + case ROOK: + ostr << "=R"; + break; + default: + ostr << "=Q"; + break; + } + return ostr.str(); +} + diff --git a/src/main.cpp b/src/main.cpp index 826a7a0..cdc6458 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -17,7 +17,9 @@ #include "parallel_support.hpp" #include +#include "database.hpp" #include "main.hpp" +#include "pgn.hpp" #include #include #include @@ -33,6 +35,7 @@ #include #include + using namespace std; double sum_exec_times2 = 0; @@ -40,6 +43,8 @@ double sum_exec_times = 0; int count_exec_times; pcounter task_counter; + + void chx_terminate() { for(int i=0;i<3;i++) std::cout << std::endl; @@ -54,6 +59,8 @@ void chx_terminate() { int auto_move = 0; int computer_side; +bool pgn_enabled = false; + #ifdef HPX_SUPPORT std::ofstream **streams; bool file_output_enabled = false; @@ -119,8 +126,10 @@ int chx_main() continue; } if (output) - std::cout << "Computer's chess_move: " << move_str(move_to_make) << " time=" << std::setprecision(3) << 1e-3*(end-start) << " sec" + std::cout << "Computer's chess_move: " << move_to_make.str() << " time=" << std::setprecision(3) << 1e-3*(end-start) << " sec" << std::endl; + if (pgn_enabled) + pgn_output(board, move_to_make); makemove(board, move_to_make); // Make the chess_move for our master board board.ply = 0; // Reset the board ply to 0 @@ -135,7 +144,7 @@ int chx_main() else print_result(workq, board); - move_to_make.set32BitMove(0); // Reset the chess_move to make + move_to_make.setBytes(0,0,0,0); // Reset the chess_move to make continue; } @@ -189,6 +198,11 @@ int chx_main() continue; } #endif + if (input[0] == "pgn") { + pgn_enabled = !pgn_enabled; + cout << "PGN output " << (pgn_enabled?"enabled.":"disabled.") << std::endl; + continue; + } if (input[0] == "new") { computer_side = EMPTY; init_board(board); @@ -331,7 +345,7 @@ int chx_main() search_m = input.at(1); } catch (out_of_range&) { - std::cout << "Name of search method (minimax,alphabeta,mtdf): "; + std::cout << "Name of search method (minimax,alphabeta,mtdf): "; std::cin >> search_m; } if (search_m == "minimax") { @@ -353,15 +367,20 @@ int chx_main() << "original" << ((chosen_evaluator == ORIGINAL) ? "=current" : "") << "," << "simple" << ((chosen_evaluator == SIMPLE) ? "=current" : "") << ")" << std::endl; - std::cout << " search \n\tswitches the current search method in use" << std::endl; - std::cout << " go\n\tcomputer makes a chess_move" << std::endl; - std::cout << " auto\n\tcomputer will continue to make moves until game is over" << std::endl; - std::cout << " new\n\tstarts a new game" << std::endl; + std::cout << " search \n\tswitches the current search method in use (" + << "minimax" << (search_method == MINIMAX ? "=current" : "") + << ",alphabeta"<< (search_method == ALPHABETA ? "=current" : "") + << ",mtdf" << (search_method == MTDF ? "=current" : "") + << ")" << std::endl; + std::cout << " go\tcomputer makes a chess_move" << std::endl; + std::cout << " auto\tcomputer will continue to make moves until game is over" << std::endl; + std::cout << " new\tstarts a new game" << std::endl; std::cout << " wd \n\tsets white search depth (currently " << depth[LIGHT] << ")" << std::endl; std::cout << " bd \n\tsets black search depth (currently " << depth[DARK] << ")" << std::endl; - std::cout << " d\n\tdisplay the board" << std::endl; + std::cout << " d\tdisplay the board" << std::endl; std::cout << " o \n\ttoggles engine output on or off (default on)" << std::endl; - std::cout << " exit\n\texit the program" << std::endl; + std::cout << " pgn\ttoggles output of moves to pgn file." << std::endl; + std::cout << " exit\texit the program" << std::endl; std::cout << " Enter moves in coordinate notation, e.g., e2e4, e7e8Q" << std::endl; std::cout << std::endl; continue; @@ -376,6 +395,8 @@ int chx_main() std::cout << "Illegal chess_move or command." << std::endl; else { makemove(board, mov); + if (pgn_enabled) + pgn_output(board, mov); board.ply = 0; workq.clear(); gen(workq, board); @@ -598,10 +619,10 @@ void start_benchmark(std::string filename, int ply_level, int num_runs,bool para } else { - std::cout << " Computer's chess_move: " << move_str(move_to_make) + std::cout << " Computer's chess_move: " << move_to_make.str() << std::endl; - logfile << " Computer's chess_move: " << move_str(move_to_make) + logfile << " Computer's chess_move: " << move_to_make.str() << std::endl; } // Allow time for aborted threads to get cleaned up @@ -676,69 +697,31 @@ int parse_move(std::vector& workq, const char *s) } -// move_str returns a string with chess_move m in coordinate notation - -char *move_str(chess_move& m) -{ - static char str[6]; - - char c; - - if (m.getBits() & 32) { - switch (m.getPromote()) { - case KNIGHT: - c = 'n'; - break; - case BISHOP: - c = 'b'; - break; - case ROOK: - c = 'r'; - break; - default: - c = 'q'; - break; - } - sprintf(str, "%c%d%c%d%c", - COL(m.getFrom()) + 'a', - 8 - ROW(m.getFrom()), - COL(m.getTo()) + 'a', - 8 - ROW(m.getTo()), - c); - } - else - sprintf(str, "%c%d%c%d", - COL(m.getFrom()) + 'a', - 8 - ROW(m.getFrom()), - COL(m.getTo()) + 'a', - 8 - ROW(m.getTo())); - return str; -} - // print_board() prints the board -void print_board(const node_t& board, std::ostream& out) +void print_board(const node_t& board, std::ostream& out,bool trimmed) { int i; - - out << std::endl << "8 "; + //if (trimmed) out<<'&'; + if (!trimmed) out << std::endl << "8 "; for (i = 0; i < 64; ++i) { + if (!trimmed) out << " "; switch (board.color[i]) { case EMPTY: - out << " ."; + out << "."; break; case LIGHT: - out << " " << piece_char[(size_t)board.piece[i]]; + out << piece_char[(size_t)board.piece[i]]; break; case DARK: char ch = (piece_char[(size_t)board.piece[i]] + ('a' - 'A')); - out << " " << ch; + out << ch; break; } if ((i + 1) % 8 == 0 && i != 63) - out << std::endl << 7 - ROW(i) << " "; + if (!trimmed) out << std::endl << 7 - ROW(i) << " "; } - out << std::endl << std::endl << " a b c d e f g h" << std::endl << std::endl; + if (!trimmed) out << std::endl << std::endl << " a b c d e f g h" << std::endl << std::endl; } diff --git a/src/minimax.cpp b/src/minimax.cpp index e9224a2..2874a16 100644 --- a/src/minimax.cpp +++ b/src/minimax.cpp @@ -137,7 +137,7 @@ score_t search(boost::shared_ptr info) if (board.ply == 0) { assert(max_move != INVALID_MOVE); - ScopedLock s(mutex); + ScopedLock s(cmutex); move_to_make = max_move; } diff --git a/src/pgn.cpp b/src/pgn.cpp new file mode 100644 index 0000000..114c123 --- /dev/null +++ b/src/pgn.cpp @@ -0,0 +1,15 @@ +#include "pgn.hpp" +#include +//#include + +using namespace std; + +const void pgn_output(const node_t &board, const chess_move &move) +{ + string piece; + piece = piece_char[(size_t)board.piece[move.getTo()]]; + if (piece == "p") + piece = ""; + cout << "pgn " << piece << (move.getCapture()?"x":"") << move.pgn() << endl; +} + diff --git a/src/search.cpp b/src/search.cpp index 7b7d3e0..273bfa5 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -23,7 +23,7 @@ #include #include -Mutex mutex; +Mutex cmutex; const int num_proc = chx_threads_per_proc(); int min(int a,int b) { return a < b ? a : b; } @@ -339,12 +339,19 @@ void sort_pv(std::vector& workq, int index) #define TRANSPOSE_ON 1 +inline int iabs(int n) { + if(n < 0) + return -n; + else + return n; +} + zkey_t transposition_table[table_size]; bool get_transposition_value(const node_t& board,score_t& lower,score_t& upper) { bool gotten = false; #ifdef TRANSPOSE_ON - int n = abs(board.hash^board.depth) % table_size; + int n = iabs(board.hash^board.depth) % table_size; zkey_t *z = &transposition_table[n]; ScopedLock s(z->mut); if(z->depth >= 0 && board_equals(board,z->board)) { @@ -361,7 +368,7 @@ bool get_transposition_value(const node_t& board,score_t& lower,score_t& upper) void set_transposition_value(const node_t& board,score_t lower,score_t upper) { #ifdef TRANSPOSE_ON - int n = abs(board.hash^board.depth) % table_size; + int n = iabs(board.hash^board.depth) % table_size; zkey_t *z = &transposition_table[n]; ScopedLock s(z->mut); if(board.depth >= z->depth) { diff --git a/src/xboard.cpp b/src/xboard.cpp index 718c8e1..08becb4 100644 --- a/src/xboard.cpp +++ b/src/xboard.cpp @@ -34,7 +34,7 @@ void xboard() computer_side = EMPTY; continue; } - std::cout << "chess_move " << move_str(move_to_make.b) << std::endl; + std::cout << "chess_move " << move_to_make.b.str() << std::endl; std::cout.flush(); makemove(board, move_to_make.b); board.ply = 0; @@ -91,7 +91,7 @@ void xboard() think(board, false); if (move_to_make.u == 0) continue; - std::cout << "Hint: " << move_str(move_to_make.b) << std::endl; + std::cout << "Hint: " << move_to_make.b.str() << std::endl; continue; } @@ -109,4 +109,4 @@ void xboard() print_result(workq, board); } } -} \ No newline at end of file +}