Skip to content
Snippets Groups Projects
Commit 37aef8b3 authored by Bariatti Francesco's avatar Bariatti Francesco
Browse files

Real situation test and corrections

parent cf46f5e9
No related branches found
No related tags found
No related merge requests found
...@@ -13,22 +13,22 @@ namespace game ...@@ -13,22 +13,22 @@ namespace game
{ {
struct penguin_state struct penguin_state
{ {
uint64_t one_fish = 0x7F59398348146BD; //Position of one-fish tiles (bitboard) uint64_t one_fish = 638390472297737852; //Position of one-fish tiles (bitboard)
uint64_t two_fish = 0x86C628366B102; //Position of two-fish tiles (bitboard) uint64_t two_fish = 513912844679577984; //Position of two-fish tiles (bitboard)
uint64_t three_fish = 0x802000548180840; //Position of three-fish tiles (bitboard) uint64_t three_fish = 615868312588291; //Position of three-fish tiles (bitboard)
//Penguins //Penguins
uint32_t p1_red = 0; uint32_t p1_red = 42;
uint32_t p2_red = 1; uint32_t p2_red = 39;
uint32_t p3_red = 8; uint32_t p3_red = 28;
uint32_t p4_red = 9; uint32_t p4_red = 10;
uint32_t p1_blue = 51; uint32_t p1_blue = 19;
uint32_t p2_blue = 52; uint32_t p2_blue = 32;
uint32_t p3_blue = 58; uint32_t p3_blue = 43;
uint32_t p4_blue = 59; uint32_t p4_blue = 49;
int score_red = 0; int score_red = 6;
int score_blue = 0; int score_blue = 3;
bool current_player_red = false; //True if red must play now bool current_player_red = false; //True if red must play now
......
...@@ -27,8 +27,8 @@ int main(int argc, char *argv[]) ...@@ -27,8 +27,8 @@ int main(int argc, char *argv[])
//game::run_test_two_players_game(game::morpion()); //game::run_test_two_players_game(game::morpion());
//mcts::run_test_mcts_two_players(game::morpion()); //mcts::run_test_mcts_two_players(game::morpion());
game::run_test_two_players_game(game::penguin()); //game::run_test_two_players_game(game::penguin());
//mcts::run_test_mcts_two_players(game::penguin()); mcts::run_test_mcts_two_players(game::penguin());
// minmax::test_minmax(); // minmax::test_minmax();
......
...@@ -15,7 +15,7 @@ namespace mcts ...@@ -15,7 +15,7 @@ namespace mcts
void copy(node* n1, node* n2, unsigned int prunning = 0); void copy(node* n1, node* n2, unsigned int prunning = 0);
public: public:
allocator(unsigned int size = 10000000U); allocator(unsigned int size = 100000000U);
~allocator(); ~allocator();
node* allocate(unsigned int size); node* allocate(unsigned int size);
void clear(); void clear();
......
...@@ -265,7 +265,7 @@ namespace mcts ...@@ -265,7 +265,7 @@ namespace mcts
} }
else else
{ {
this->root = alloc_.move(&this->root->get_children()[move]); this->root = alloc_.move(&this->root->get_children()[move], 20);
} }
} }
......
...@@ -69,7 +69,7 @@ namespace mcts ...@@ -69,7 +69,7 @@ namespace mcts
void test_mcts_two_players<Game>::play(Game g) void test_mcts_two_players<Game>::play(Game g)
{ {
// ProfilerStart("theturk.prof"); // 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 << "play one game" << std::endl;
std::cout << "who's first? (h)uman/(c)omputer "; std::cout << "who's first? (h)uman/(c)omputer ";
std::string ans; std::string ans;
......
...@@ -9,6 +9,7 @@ if __name__ == "__main__": ...@@ -9,6 +9,7 @@ if __name__ == "__main__":
programname = os.path.join(os.path.dirname(__file__), "../bin/theturk") 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) program = subprocess.Popen(programname, stdin = subprocess.PIPE, stdout = subprocess.PIPE, universal_newlines = True, bufsize = 1)
try: try:
program.stdin.write("h\n")
while True: while True:
#READ #READ
readloop = True readloop = True
...@@ -17,7 +18,8 @@ if __name__ == "__main__": ...@@ -17,7 +18,8 @@ if __name__ == "__main__":
brackets_count = 0 brackets_count = 0
while readloop: while readloop:
line = program.stdout.readline() 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("Red move: ", "")
line = line.replace("Blue move: ", "") line = line.replace("Blue move: ", "")
if line.startswith("{"): #Reading json if line.startswith("{"): #Reading json
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment