Win/Lose Detection
Learn how to detect the game state.
By the end of this lesson, you will:
Implement
check_game_state(board, target=2048) -> str.Detect a win: at least one
tile ≥ target.Detect a loss: no empty cells and no possible merges horizontally or vertically.
Keep game state logic separate from the main loop and move logic.
Integrate
check_game_stateintomain()so the game actually ends.Use AI to:
Clarify the rules
Implement helpers like
has_wonandhas_any_movesGenerate test boards for each state
We start from the ...