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

Corrected some mistakes

parent c7b2a2ce
No related branches found
No related tags found
No related merge requests found
......@@ -138,14 +138,18 @@ namespace game
//cout << "Possible moves: " << state.possible_moves << endl;
}
//Play the move m. m is the position on the board of where you want to play
//Play the mth move in the possible moves list.
void morpion::play(uint16_t m)
{
//cout << "You choose move " << m << endl;
uint64_t possible_moves = state.possible_moves;
possible_moves = possible_moves >> 4*m; //A move is coded with 4 bit
uint16_t move = possible_moves & 15; //15 = 1111
//cout << "You choose the possible move number " << m << endl;
//cout << "You choose move " << move << endl;
if (current_player() == CROSS)
state.cross_bitboard |= (((uint16_t) 1) << m);
state.cross_bitboard |= (((uint16_t) 1) << move);
else
state.circle_bitboard |= (((uint16_t) 1) << m);
state.circle_bitboard |= (((uint16_t) 1) << move);
//State update
state.total_moves++;
......@@ -207,8 +211,7 @@ namespace game
{
uniform_int_distribution<uint16_t> distribution(0, 8-state.total_moves);
uint16_t move = distribution(engine);
uint16_t position = (state.possible_moves >> 4*move) & 15; //15 is the mask to get only one move
play(position);
play(move);
}
}
......
......@@ -31,7 +31,7 @@ namespace game
{
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;
movesMap[mor.move_to_string(move)] = move; //In the map: the move as seen by the player and its representation for the computer
movesMap[mor.move_to_string(move)] = i; //In the map: the move as seen by the player and its representation for the computer
possible_moves = possible_moves >> 4;
}
string move;
......@@ -51,7 +51,7 @@ namespace game
void test_morpion::playout()
{
morpion mor;
auto mctsPlayer = mcts::make_mcts_two_players(mor, 5000, 0.3, 4);
auto mctsPlayer = mcts::make_mcts_two_players(mor, 5000, 0.3, 4); // creation du player a partir du morpion. 5000: ms de reflexion 0.3 fateur d'exploration 4: nb_visit_before_expansion on attend d'etre arrive 4 fois sur un noeud avant de le developper
cout << "Player vs Computer game!" << endl;
cout << "Who's first? (Player)" << endl;
while(!mor.end_of_game())
......@@ -60,7 +60,8 @@ namespace game
if(mor.current_player() == 1) //It's circle turn (computer is circle)
{
uint16_t move = mctsPlayer.select_move();
cout << "Computer wants to play " << mor.move_to_string(move);
//cout << "Computer played " << mor.move_to_string(move) << endl;
mor.play(move);
}
else //Human turn to play
{
......@@ -72,7 +73,7 @@ namespace game
{
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;
movesMap[mor.move_to_string(move)] = move; //In the map: the move as seen by the player and its representation for the computer
movesMap[mor.move_to_string(move)] = i; //In the map: the move as seen by the player and
possible_moves = possible_moves >> 4;
}
string move;
......
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