Skip to content
Snippets Groups Projects
test_morpion.cpp 870 B
Newer Older
#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;
			}
		}
	}

}