From 111ce29c9dc3909df8efc9db6ae55ff6c54c7909 Mon Sep 17 00:00:00 2001 From: Jan-Eric Nitschke <47750513+JanEricNitschke@users.noreply.github.com> Date: Tue, 24 Oct 2023 16:28:00 +0200 Subject: [PATCH] Always make a random first move even if depth is lower than maximum allowed. --- tictactoe_cpp/include/tictactoe.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tictactoe_cpp/include/tictactoe.h b/tictactoe_cpp/include/tictactoe.h index e4aa4dd..512844b 100644 --- a/tictactoe_cpp/include/tictactoe.h +++ b/tictactoe_cpp/include/tictactoe.h @@ -364,7 +364,7 @@ BestMoves getBestMoves(char player, GameBoard *board, // and increase replayability // just do a random move as the first // Optimal play still forces a draw - if (empty_cells.size() >= max_depth) { + if (empty_cells.size() >= max_depth || empty_cells.size() == N * N) { Move heuristic_move{randomMove(*board)}; best_moves.spots.push_back(heuristic_move.spot); return best_moves;