liveBook · Manning

Final state

As explained in Classic Computer Science Problems in Swift: Essential techniques for practicing programmers

A terminal position is a game state at which play ends because a player has won or the game is drawn.

A terminal position is a game state where play ends in a win or a draw. In minimax, it is a base case: the outcome receives a score that returns through the recursive search. section 8.4

    var isDraw: Bool {
        return !isWin && legalMoves.count == 0
    }
}

A tic-tac-toe position is a draw when it is not a win and has no legal moves. section 8.4

The example assigns 1 to a win for the player being evaluated, -1 to a loss, and 0 to a draw. For games with search too deep to reach an actual terminal position, minimax can stop at a chosen depth and use a heuristic evaluation instead. section 8.4

How Classic Computer Science Problems in Swift: Essential techniques for practicing programmers covers it

How deep it goes
Defines wins and draws and traces their scores through minimax; notes depth cutoffs but does not detail heuristic design.
Examples
Uses tic-tac-toe wins and draws as terminal cases, scoring them 1, -1, or 0.
What you can do after
Evaluate a terminal game position as a win, loss, or draw for the player being considered.
How it connects
Connects terminal positions to minimax, tic-tac-toe, and heuristic evaluation functions.

Also explained in

Compare how 2 books explain final state →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Classic Computer Science Problems in Swift: Essential techniques for practicing programmers. The section links point to the parts of the book it draws on.