Help determining best strategy to play a game

80 Views Asked by At

The game is a simple version of tic tac toe which this YouTuber made rules of the game are simple

  • tic-tac-toe like 3 x 3 Grid
  • p1 can place horizontal marks and p2 can place vertical marks
  • players cant mark on location just previously marked by another player
  • players cant mark on their own mark
  • whoever makes a row, col, or diagonal of both marks wins first

since the game cannot be a draw and moves are finite at max 9^15 (the game has to finish in 15 moves in any circumstance) who has more advantage p1 or p2? and what would the best strategy to play be like I ran a python code for the same and got about a million win sequences it was nowhere near done so was thinking is there any mathematical way to solve this

1

There are 1 best solutions below

0
On BEST ANSWER

I think this game is a win for the second player. To describe the strategy let me first define some notation.

The top left corner is $(1,1)$ and the bottom right corner is $(3,3)$ in general $(i,j)$ is the i-th row and j-th column. The corners are $C = \{(1,1), (1,3), (3,1), (3,3)\}$, the sides are $S = \{(1,2), (2,1), (2,3), (3,2)\}$, and the middle is $M = \{(2,2)\}$.

Player 2's first 6 moves will make the pattern

$ | X | X | \phantom{X} | \\ | X | \phantom{X} | X | \\ | \phantom{X} | X | X | $

or

$ | \phantom{X} | X | X | \\ | X | \phantom{X} | X | \\ | X | X | \phantom{X} | $

Here is the list of rules for player 2 to always win:

  1. The first time player 1 puts a mark in a corner place a mark in the "opposite" corner.
  • If player 1 puts a mark in (1,1) place a mark in (3,3)
  • If player 1 puts a mark in (1,3) place a mark in (3,1)
  • If player 1 puts a mark in (3,1) place a mark in (1,3)
  • If player 1 puts a mark in (3,3) place a mark in (1,1)
  1. Place a mark on an empty side, if all the sides are marked then place a mark on a side that is only marked by player 1. If there is only 1 side left that player 2 hasn't marked and player 1's last move occupied that cell then place a mark on top of the first corner player 1 marked (This scenario can only occur if player 2 has marked 3 sides and then player 1 marks the last unmarked side. Player 1 would have placed 3 marks before this, where none of the cells is a side, and therefore one of these marks would have to be a corner. This means that player 2 can always "place a mark on top of the first corner player 1 marked" in this scenario).
  2. Once player 2 has marked all the sides, place a mark on top of the first mark player 1 put on a corner. If there are no marks then the board has both players' marks on all the sides and player 1 placed a mark in the middle. If player 1's last move wasn't in the middle (player 1 has a mark in the middle, it was just not placed on the last move) then place your mark in the middle and win the game. Otherwise, place your mark in any corner and the next turn place your mark in the middle and win the game.

At this point, player 2 will have one of the two patterns above and there is one corner that has both players' mark. Player 1 would have placed 7 marks (and 1 is a shared corner).

  1. If on turn 7 (for player 2) there are two or more cells that player 1 has marked that player 2 hasn't marked then player 2 can place a mark to win the game. If there is only 1 mark, then player 2 can either place their mark to win the game or the winning square was just marked and player 2 can place their mark on any cell and win the game on the next turn.

You can check for yourself if player 2 makes one of the two patterns above and player 1 has placed 7 marks (with 1 shared corner) then player 2 will always win. The key is that player 2 shares a corner with player 1 when reaching this position.