Блог пользователя _Evoiz_

Автор _Evoiz_, история, 7 лет назад, По-английски

what is the best way to solve this problem ? game theory? we have N*M empty grid and we have two players each player in his turn take an empty cell and put "X" in it game end when a player can make line with three "X" (like tik-tak-too game) players play optimally so who is the winier in this game?

  • Проголосовать: нравится
  • +15
  • Проголосовать: не нравится

»
7 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Auto comment: topic has been updated by _Evoiz_ (previous revision, new revision, compare).

»
7 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Auto comment: topic has been updated by _Evoiz_ (previous revision, new revision, compare).

»
7 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

What are the constraints on n, m? If they are very small, then we can do masking to solve this problem.

»
7 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Do diagonal lines also count?

»
7 лет назад, скрыть # |
Rev. 4  
Проголосовать: нравится 0 Проголосовать: не нравится

Edited: Sorry, I totally misunderstood problem.

»
7 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Since the player wins when 3 X's are together, the below solution assumes that either of m or n is greater than or equal to 3.

Player 1 wins only when both m and n are odd. Else player two will win.

The logic is simple. Suppose that either of m or n is not odd. Hence player 2 can always mimic turn of player 1 and upon getting appropriate chance it can make the winning move.

Where as if both m and n are odd, player 1 will place first X in the center square of grid and then player 1 will mimic each turn of player 2 thus on getting appropriate chance player 1 will make the winning move.

Thus player 1wins if both m and n are odd else player 2 wins

»
7 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Can you please provide link to the problem so that we can also learn

»
7 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Quoting from this article. A 3-in-a-row game is a winning game for Player 1 if and only if N >= 3 and M >= 4 (number of row and column can be swapped). Otherwise, it's a draw game (3x3 or smaller grid).