diff --git a/src/game/morpion.cpp b/src/game/morpion.cpp index 72191bc20f6dd97a9929c21686ba5cbdaa95d1cf..8cf7aaf11af03c23090d4fc8975b6c94ab739379 100644 --- a/src/game/morpion.cpp +++ b/src/game/morpion.cpp @@ -74,7 +74,12 @@ namespace game int morpion::value(uint8_t player) const { - //TODO: Implement + if (player == CROSS) { + return state.first_player_win? 1 : (state.second_player_win? -1 : 0) + } + else if (player == CIRCLE) { + return state.second_player_win? 1 : (state.first_player_win? -1 : 0) + } return 0; } @@ -111,17 +116,25 @@ namespace game { //TODO: Implement } - + + + /** + * player_to_string + * Retourne X si le joueur joue les croix, O s'il joue les ronds, + * et un espace sinon. + */ string morpion::player_to_string(uint8_t player) const { - //TODO: Implement - return "TODO"; + return player == CROSS ? "X" : (player == CIRCLE ? "O" : " "); } - + + string morpion::move_to_string(uint16_t m) const { - //TODO: Implement - return "TODO"; + uint8_t row = m/3; + uint8_t col = m%3; + return "( "std::to_string(row)", "std::to_string(col)" )"; + } set<int> morpion::to_input_vector() const @@ -135,8 +148,8 @@ namespace game string morpion::to_string() const { - //TODO: Implement - return "TODO"; + for (int i = 0 + //TODO PAR ROMAIN } void morpion::playout(mt19937& engine, int max_depth)