From 37aef8b30b3905ba2f2b720d34ccf824f8f1503b Mon Sep 17 00:00:00 2001 From: Francesco Bariatti <francesco.bariatti@insa-rennes.fr> Date: Mon, 21 Mar 2016 16:05:58 +0100 Subject: [PATCH] Real situation test and corrections --- src/game/penguin.hpp | 26 +++++++++++++------------- src/main/main.cpp | 4 ++-- src/mcts/allocator.hpp | 2 +- src/mcts/mcts_two_players.hpp | 2 +- src/mcts/test_mcts_two_players.hpp | 2 +- tools/gui.py | 4 +++- 6 files changed, 21 insertions(+), 19 deletions(-) diff --git a/src/game/penguin.hpp b/src/game/penguin.hpp index 55cb68b..c97f01b 100644 --- a/src/game/penguin.hpp +++ b/src/game/penguin.hpp @@ -13,22 +13,22 @@ namespace game { struct penguin_state { - uint64_t one_fish = 0x7F59398348146BD; //Position of one-fish tiles (bitboard) - uint64_t two_fish = 0x86C628366B102; //Position of two-fish tiles (bitboard) - uint64_t three_fish = 0x802000548180840; //Position of three-fish tiles (bitboard) + uint64_t one_fish = 638390472297737852; //Position of one-fish tiles (bitboard) + uint64_t two_fish = 513912844679577984; //Position of two-fish tiles (bitboard) + uint64_t three_fish = 615868312588291; //Position of three-fish tiles (bitboard) //Penguins - uint32_t p1_red = 0; - uint32_t p2_red = 1; - uint32_t p3_red = 8; - uint32_t p4_red = 9; - uint32_t p1_blue = 51; - uint32_t p2_blue = 52; - uint32_t p3_blue = 58; - uint32_t p4_blue = 59; + uint32_t p1_red = 42; + uint32_t p2_red = 39; + uint32_t p3_red = 28; + uint32_t p4_red = 10; + uint32_t p1_blue = 19; + uint32_t p2_blue = 32; + uint32_t p3_blue = 43; + uint32_t p4_blue = 49; - int score_red = 0; - int score_blue = 0; + int score_red = 6; + int score_blue = 3; bool current_player_red = false; //True if red must play now diff --git a/src/main/main.cpp b/src/main/main.cpp index 19f8c24..181e630 100644 --- a/src/main/main.cpp +++ b/src/main/main.cpp @@ -27,8 +27,8 @@ int main(int argc, char *argv[]) //game::run_test_two_players_game(game::morpion()); //mcts::run_test_mcts_two_players(game::morpion()); - game::run_test_two_players_game(game::penguin()); - //mcts::run_test_mcts_two_players(game::penguin()); + //game::run_test_two_players_game(game::penguin()); + mcts::run_test_mcts_two_players(game::penguin()); // minmax::test_minmax(); diff --git a/src/mcts/allocator.hpp b/src/mcts/allocator.hpp index f765282..f887fdc 100644 --- a/src/mcts/allocator.hpp +++ b/src/mcts/allocator.hpp @@ -15,7 +15,7 @@ namespace mcts void copy(node* n1, node* n2, unsigned int prunning = 0); public: - allocator(unsigned int size = 10000000U); + allocator(unsigned int size = 100000000U); ~allocator(); node* allocate(unsigned int size); void clear(); diff --git a/src/mcts/mcts_two_players.hpp b/src/mcts/mcts_two_players.hpp index b640dc6..10555e0 100644 --- a/src/mcts/mcts_two_players.hpp +++ b/src/mcts/mcts_two_players.hpp @@ -265,7 +265,7 @@ namespace mcts } else { - this->root = alloc_.move(&this->root->get_children()[move]); + this->root = alloc_.move(&this->root->get_children()[move], 20); } } diff --git a/src/mcts/test_mcts_two_players.hpp b/src/mcts/test_mcts_two_players.hpp index e8c1033..974a57e 100644 --- a/src/mcts/test_mcts_two_players.hpp +++ b/src/mcts/test_mcts_two_players.hpp @@ -69,7 +69,7 @@ namespace mcts void test_mcts_two_players<Game>::play(Game g) { // ProfilerStart("theturk.prof"); - auto the_turk = make_mcts_two_players(g, 5000, 0.3, 4); + auto the_turk = make_mcts_two_players(g, 20000, 0.4, 8); std::cout << "play one game" << std::endl; std::cout << "who's first? (h)uman/(c)omputer "; std::string ans; diff --git a/tools/gui.py b/tools/gui.py index 7be949b..3842f44 100755 --- a/tools/gui.py +++ b/tools/gui.py @@ -9,6 +9,7 @@ if __name__ == "__main__": programname = os.path.join(os.path.dirname(__file__), "../bin/theturk") program = subprocess.Popen(programname, stdin = subprocess.PIPE, stdout = subprocess.PIPE, universal_newlines = True, bufsize = 1) try: + program.stdin.write("h\n") while True: #READ readloop = True @@ -17,7 +18,8 @@ if __name__ == "__main__": brackets_count = 0 while readloop: line = program.stdout.readline() - print(line) + #print(line) + line = line.replace("who's first? (h)uman/(c)omputer ", "") line = line.replace("Red move: ", "") line = line.replace("Blue move: ", "") if line.startswith("{"): #Reading json -- GitLab