diff --git a/src/game/morpion.cpp b/src/game/morpion.cpp
index 9235c8cfdd88c798ff6b3af59e754ff911fa13e7..dcb0fabfdc5350ba26db90aabb0365a852104d4f 100644
--- a/src/game/morpion.cpp
+++ b/src/game/morpion.cpp
@@ -103,11 +103,11 @@ namespace game
 
 	bool morpion::has_won(uint16_t bitboard)
 	{
-		if(bitboard == ROW0_MASK || bitboard == ROW1_MASK || bitboard == ROW2_MASK) // Check vertical |
+		if(((bitboard | ROW0_MASK) == ALL_ONES) || ((bitboard | ROW1_MASK) == ALL_ONES) || ((bitboard | ROW2_MASK) == ALL_ONES)) // Check horizontal ---
 			return true;
-		if(bitboard == COL0_MASK || bitboard == COL1_MASK || bitboard == COL2_MASK) // Check horizontal _
+		if(((bitboard | COL0_MASK) == ALL_ONES) || ((bitboard | COL1_MASK) == ALL_ONES) || ((bitboard | COL2_MASK) == ALL_ONES)) // Check vertical |
 			return true;
-		if(bitboard == DIA0_MASK || bitboard == DIA1_MASK) // Chack diagonal \ /
+		if(((bitboard | DIA0_MASK) == ALL_ONES) || ((bitboard | DIA1_MASK) == ALL_ONES)) // Chack diagonal \ /
 			return true;
 		return false;
 	}
@@ -116,6 +116,7 @@ namespace game
 	void morpion::update_moves()
 	{
 		uint16_t free_bitboard = ~(state.cross_bitboard | state.circle_bitboard);
+		state.possible_moves = 0;
 		for(int i = 0; i <=8; i++)
 		{
 			if(free_bitboard & 1)
@@ -129,11 +130,10 @@ namespace game
 
 	void morpion::play(uint16_t m)
 	{   
-		uint16_t position = (state.possible_moves >> 4*m) & 15; //15 is the mask to get only one move
 		if (current_player() == CROSS)
-			state.cross_bitboard += 1 << position;
+			state.cross_bitboard += (1 << m);
 		else
-			state.circle_bitboard += 1 << position;
+			state.circle_bitboard += (1 << m);
 		
 		//State update
 		state.total_moves++;
@@ -179,9 +179,9 @@ namespace game
 			result += "|";
 			for (int col = 2; col >= 0; col--)
 			{
-				if(((state.cross_bitboard >> 3*row) >> col) & 1)
+				if(((state.cross_bitboard >> (3*row)) >> col) & 1)
 					result += player_to_string(CROSS)+"|";
-				else if (((state.circle_bitboard >> 3*row) >> col) & 1)
+				else if (((state.circle_bitboard >> (3*row)) >> col) & 1)
 					result += player_to_string(CIRCLE)+"|";
 				else
 					result += " |";
@@ -197,7 +197,8 @@ namespace game
 		{
 			uniform_int_distribution<uint16_t> distribution(0, 8-state.total_moves);
 			uint16_t move = distribution(engine);
-			play(move);
+			uint16_t position = (state.possible_moves >> 4*move) & 15; //15 is the mask to get only one move
+			play(position);
 		}
 	}
 
diff --git a/src/game/morpion.hpp b/src/game/morpion.hpp
index 052f50577e30c2d40cee5a46e4bbaa35f86f3dd7..0b74afda81840c46f8ac448e40b297d506711e59 100644
--- a/src/game/morpion.hpp
+++ b/src/game/morpion.hpp
@@ -66,6 +66,7 @@ namespace game
 			const uint16_t COL2_MASK = 219;
 			const uint16_t DIA0_MASK = 238;
 			const uint16_t DIA1_MASK = 427;
+			const uint16_t ALL_ONES = 511;
 
 			static std::vector<std::vector<uint64_t>> cross_hash_values;
 			static std::vector<std::vector<uint64_t>> circle_hash_values;