Skip to content

Commit

Permalink
Always make a random first move even if depth is lower than maximum a…
Browse files Browse the repository at this point in the history
…llowed.
  • Loading branch information
JanEricNitschke committed Oct 24, 2023
1 parent 71626f7 commit 111ce29
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion tictactoe_cpp/include/tictactoe.h
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ BestMoves getBestMoves(char player, GameBoard<N> *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;
Expand Down

0 comments on commit 111ce29

Please sign in to comment.