diff --git a/Makefile b/Makefile index 2edead2290dc4bffdf6996f786e6d4b44fe187b6..d6f8f1fba0fa1f0c99d825e57b3eabc238fab40a 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ BIN=bin INCLUDE=-I src/game -I src/util -I src/monte_carlo -I src/mcts -I src/minmax CFLAGS=-g -O3 -ffast-math -fopenmp -c -Wall -std=c++11 $(INCLUDE) LDFLAGS=-fopenmp -std=c++11 #-lprofiler -Wl,-no_pie -SOURCES=omp_util.cpp fast_log.cpp display_node.cpp morpion.cpp connect4.cpp test_connect4.cpp monte_carlo.cpp test_monte_carlo.cpp test_fast_log.cpp\ +SOURCES=omp_util.cpp fast_log.cpp display_node.cpp morpion.cpp test_morpion.cpp monte_carlo.cpp test_monte_carlo.cpp test_fast_log.cpp\ statistics.cpp node.cpp allocator.cpp test_allocator.cpp openings.cpp mcts_two_players.cpp test_mcts_two_players.cpp test_minmax.cpp\ bits.cpp test_bits.cpp main.cpp OBJECTS=$(addprefix $(BIN)/, $(SOURCES:.cpp=.o)) diff --git a/src/game/test_morpion.cpp b/src/game/test_morpion.cpp new file mode 100644 index 0000000000000000000000000000000000000000..21af4d3931ab29522d9e40a2d1fc137b3f37b491 --- /dev/null +++ b/src/game/test_morpion.cpp @@ -0,0 +1,36 @@ +#include "morpion.hpp" +#include "test_morpion.hpp" +#include <iostream> +#include <map> + +using namespace std; + + +namespace game +{ + test_morpion::test_morpion() + { + play(); + } + + void test_morpion::play() + { + morpion mor; + cout << "Player vs Player game!" << endl; + while(!mor.end_of_game()) + { + cout << mor << endl; + cout << "It's" << mor.player_to_string(mor.current_player()) << "turn." << endl; + map<string, int> m; + uint64_t possible_moves = mor.get_state().possible_moves; + for (int i = 0; i < mor.number_of_moves(); i++) + { + uint16_t move = possible_moves & ((uint64_t) 15); //15 = 1111 (a move is on 4 bits) + cout << "Possible move: " << mor.move_to_string(move) << endl; + m[mor.move_to_string(move)] = i; //In the map: the move as seen by the player and its index in possible moves + possible_moves = possible_moves >> 4; + } + } + } + +} diff --git a/src/game/test_morpion.hpp b/src/game/test_morpion.hpp new file mode 100644 index 0000000000000000000000000000000000000000..f1663ab07e4707c2f934cda99b55c400949133e0 --- /dev/null +++ b/src/game/test_morpion.hpp @@ -0,0 +1,14 @@ +#ifndef __TEST_MORPION_HPP__ +#define __TEST_MORPION_HPP__ + +namespace game +{ + class test_morpion + { + //void playout(); + void play(); + public: + test_morpion(); + }; +} +#endif diff --git a/src/main/main.cpp b/src/main/main.cpp index 5451eeb95b87ee841a20052a3f86ec3b07615e54..075076f250c4410c14d665fd05d2c7c838320f60 100644 --- a/src/main/main.cpp +++ b/src/main/main.cpp @@ -1,4 +1,5 @@ -#include "test_connect4.hpp" +//#include "test_connect4.hpp" +#include "test_morpion.hpp" #include "test_monte_carlo.hpp" #include "test_fast_log.hpp" #include "test_allocator.hpp" @@ -13,14 +14,15 @@ using namespace std; int main(int argc, char *argv[]) { - // game::test_connect4(); - // util::test_fast_log(100000000); - // mcts::test_allocator(10, 2); - // omp_set_num_threads(8); - mcts::test_mcts_two_players(); - // minmax::test_minmax(); - //util::test_bits(200000000); - //game::connect4 c4; - // util::learning::display_file(c4, "learning_examples.txt"); - return 0; + // game::test_connect4(); + game::test_morpion(); + // util::test_fast_log(100000000); + // mcts::test_allocator(10, 2); + // omp_set_num_threads(8); + //mcts::test_mcts_two_players(); + // minmax::test_minmax(); + //util::test_bits(200000000); + //game::connect4 c4; + // util::learning::display_file(c4, "learning_examples.txt"); + return 0; }