Game states
Let us consider a game where there is initially a heap of n-sticks. Players A and B move alternately, and player A begins. On each move, the player has to remove 1, 2, or 3 sticks from the heap, and the player who removes the last stick wins the game.
For example, if n = 10, the game may proceed as follows:
- A → removes 2 sticks (8 sticks left).
- B → removes 3 sticks (5 sticks left).
- A → removes 1 stick (4 sticks left)
- B → removes 2 sticks (2 sticks left).
- A → removes 2 sticks and wins
This game consists of states 0, 1, 2,…, n, where the number of the state corresponds to the number of sticks left.
A few examples of Game states are:
- Tic Tac Toe = Tic Tac Toe is a classic two-player game where the players take turns placing either X or O in a 3×3 grid until one player gets three in a row horizontally, vertically, or diagonally, or all spaces on the board are filled.
- Rock-Paper-Scissors = Rock-Paper-Scissors is a simple two-player game where each player simultaneously chooses one of three options (rock, paper, scissors). The winner is determined by a set of rules, rock beats scissors, scissors beat paper, and paper beats rock.
Game Theory
Game Theory is a topic in competitive programming that involves a certain type of problem, where there are some players who play a game based on given rules and the task is often to find the winner or the winning moves. Game Theory is often asked in short contests with a mixture of other topics like range querying or greedy or dynamic programming.
Game Theory for Competitive Programming
- Objectives Game Theory for Competitive Programming:
- 1. Game states:
- 2. Winning and Losing states:
- 3. Nim game:
- 4. Misère game:
- 5. Sprague–Grundy theorem:
- 6. Grundy numbers:
- 7. Subgames:
- 8. Grundy’s game:
- Practice Problems on Game Theory