ecosmak.ru

Secrets of board games: how to win at tic-tac-toe. Tic-tac-toe of a new generation Tic-tac-toe tactics

Tic-tac-toe is a solved game. This means that there is a mathematically proven strategy with which you can achieve the best result in each game. In tic-tac-toe, two players who use the correct strategy will always end in a draw, that is, without a winner. Against an opponent who does not know this strategy, it is still possible to win if he makes a mistake. Once your friends get the gist of your strategy, try more difficult option rules.


Learn the basic rules if you don't know how to play tic-tac-toe.

Steps

Win or draw if you go first

    Put the first X in the corner. The most experienced players, if they make the first move, put an X in the corner. So the opponent will the largest number opportunities to make a mistake. If your opponent responds by betting O in any other place, except for the central cell, this guarantees you victory.

    Try to win if your opponent puts the first O in the center square. If your opponent puts his first O in the center, you will have to wait until he makes a mistake so you can win. If he continues to play correctly, then it is guaranteed to bring the result of the game to a draw. Here are two options for your next move, with instructions on how to move on if your opponent makes a certain move (and if not, then just keep blocking his moves to bring the result to a draw):

    You win automatically if your opponent puts his first O in any cell except the center one. If your opponent puts his first O in any square near the center, you can win. In response, place your second X in any other corner so that there is an empty cell between the two Xs.

    Place a third X so that you get two possible winning moves. Most likely, your opponent will see that you have two Xs in a row and block you. (If not, win by making a row of three X's). After that, there should be an empty square in line with your first and second X, and no enemy O is blocking this line. Put a third X in this cell.

    • For example, draw a tic-tac-toe field on a piece of paper with "X O _" on the top line, "O _ _" on the middle line, and "X _ _" on the bottom line. If you put a third X in the lower right corner, it will be in line with your other crosses.
  1. Win by betting the fourth X. After your third X, there are two spaces left, by occupying which you will win the game. Since your opponent can only make one move, he can only block one of these squares. Put the fourth X in an unlocked cell and you win!

    How not to lose when you go second

    1. Bring the game to a draw if you move second. If the opponent starts first and places an O in the corner, always place an X in the center square. The second X should be placed in the middle, Not corner, cage, If only you don't have to block your opponent's move so he doesn't line up three O's. With this strategy, every game usually ends in a draw. Theoretically, you can win in this situation, but your opponent must make a fatal mistake, for example, not seeing that you have two Xs in the same row.

      • In this section, your opponent is still playing with zeros, but remember that he starts to move first.
    2. Achieve a draw if your opponent starts from the center square. When your opponent starts the game by placing an O in the center square, place the first X in the corner. After that, just block the opponent's moves and you will get a draw. In this situation, there is no way to win, unless your opponent stops rushing to win!

      Try to win if the opponent starts to move from the edge cell. Most likely, your opponent will move as described above. However, if he puts his first O in an edge cell that is not a corner or center one, you have a small chance of winning. Put the first X in the center. If the opponent puts his O from the opposite edge so that the line is O-X-O, put your third X in the corner square. Then, if your opponent puts his third O on the outermost square next to your X so that the line is O-X-O, put the third X in the square to block the line of two Os. From now on, you can always win by betting your fourth H.

    Varieties of tic-tac-toe

      Try these variations if your tic-tac-toe games always end in draws. It might be fun to be invincible at tic-tac-toe for a while, but even without this article, your friends might be able to figure out how to keep you from winning. Once that happens, every game you play with them will end in a draw. But with the help of the basic rules of tic-tac-toe, it is possible to play games that have not yet been solved. Try it - these games are described below.

The main principle is to create a situation in which 2 lines are almost filled at once. Then the opponent's move no longer matters (see the figure, numbers - the order of moves). To create such a situation, it is most advantageous to occupy the middle of the field.

2 step

Consider a situation where you start and put a cross in the center. The opponent has the choice to place a zero in a corner or in the center of a line. If he chooses option 2, he has already lost. You just need to put the next cross as in the picture (turn the field depending on the opponent's move). The number 4 marks the forced move of the “zero” to protect the inclined line. The number 5 marks your next move to create a hopeless situation.

3 step

If the opponent chooses the first option, then you need to put a cross in the opposite corner (see Fig.). The opponent will have the choice to put a zero in position 4 or 5 (similarly on the second line). If he chooses 4, then you put a cross in position 5 and win, if the opponent chooses position 5, then you end up with a draw (there is still an extremely illogical move to one of positions 6, then put a cross in the second 6 and again you win) . If you put a cross (on the 3rd move) in any other place, then there will automatically be a draw.

4 step

Consider the situation when the opponent starts. If he put a zero in the center, then you need to go on the defensive and make a draw. You have to put a cross in the corner. Further see the previous step (on the “other” side).

5 step

If the opponent puts a zero in the center of the line (as in the figure), then you cannot put a cross in the cells marked in red. Otherwise, the opponent will make a move to position 3 (on the side where you put the cross), and then to the center and you lose. It is best to take the center, and then, if possible, take one of the 3 positions. This will ensure either a draw or your win (watch out for the possibility of creating a combination described in step 1, for example, if the opponent puts a zero on the opposite side, then taking 3 position will create a winning situation automatically).

6 step

If the opponent puts a zero in a corner, then there are many options. On fig. illegal moves are presented (top row) and typical mistakes. If they are avoided, it will be a draw.

7 step

If you start, you can also start your turn off the center. See the previous two steps by putting yourself in the place of the zeros. Thus, it is most advantageous to start the move in the corner of the field, since only 2 out of 8 paths are left for the enemy, it is more likely that he will make a mistake.

In the first article, various options for solving the problem are analyzed, but there is no implementation in the form of a game, in the second - there is a game, but the computer “plays” rather weakly. I decided to make my version of gomoku with blackjack a fairly strong computer game. Posting about what happened. For those who love immediately into battle - the game itself.

To begin with, I want to decide on the main points. Firstly, there are many varieties of the gomoku game, I settled on this option: the playing field is 15x15, the crosses go first, the one who first builds 5 in a row wins. Secondly, for simplicity, I will call the game algorithm for calculating a move by a computer AI.

Thank you for your attention. I hope you enjoyed reading and playing as much as I did :)

P.S. A small request, if you win easily - please attach a screenshot of the game and moves (from the console logs) for analysis and improvement of the algorithm.

Update 1
1. Increased the importance of weights for attack by 10%. Now attack for AI is preferable to defense, all other things being equal. For example, if both the AI ​​and the user have 4ka, then the AI ​​will prefer to win.

2. Changed the values ​​of the weights according to the templates. With a more precise balance of weights, you can achieve the best game AI.
The weight values ​​for the templates are now:
99999 - xxxxx - five in a row (final payline)
7000 - _xxxx_ - open four
4000 - _xxxx - half-closed four (two such fours are preferable to one open, perhaps " more interesting game" will)
2000 - _x_xxx, _xx_xx, _xxx_x - half closed four with a gap
3000 - _xxx_ - open three
1500 - _xxx - half closed three
800 - _xx_x, _x_xx - half-closed three with a gap
200 - _xx_ open deuce
Also, small weights (from 1 to 20-30) are around all moves, to create a "small move randomness".

Tic-tac-toe is a rather simple game. A small number of cells - there are only nine of them - leads to a limited number of moves. Therefore, it was quite easy for mathematicians to study this game. Therefore, classic tic-tac-toe is a solvable game, that is, there is a single strategy that unambiguously leads to a win or a draw. How to defeat the enemy?

When the first move is given to you

If you must go first, then, without further ado, place your "figure" - let it be a cross - in the very corner. This can ensure you win if the opponent does not guess to put his zero on the central field. If his zero will stand in the extreme, but not the corner field, then you should place the second cross in another corner, spaced from the first in the vertical or horizontal direction (but not in contact with this zero). The opponent will have to put his piece between your crosses, and you calmly put the third cross in the third corner. Then two winning directions are formed at once. The opponent cannot bet two zeros at the same time, therefore, you win.

But what if your partner drew their first zero in the center? Then you won't be able to win, but you can lead the game to a draw. The next cross should be in the opposite corner to make a diagonal X-O-X line. If after that the opponent places his zero in one of the corner fields, then you will win - it is enough to put the third cross in the remaining corner, forming two pay lines. If the opponent made a move to another cell, then this will lead to a draw - unless, of course, you make a mistake.

It is also possible to place a second cross in an extreme but not corner cell that does not touch your first cross. If the opponent makes his next move in the corner, then with your third cross you must block his line and create a winning situation. Otherwise, the outcome of the game will be a draw.

If you are playing second

If the opponent moves first and makes unmistakable moves, then the only possibility is to create a draw. From the above, you can understand that your first move must be made on the central field. Your second cross must be placed in the side, but not in the corner cell, if there is no need to block the opponent's line. Adhering to this strategy, you can create a coveted draw.

If the opponent makes his initial move in the center, then you put your cross in the corner. In the future, you need to fend off the threats of the enemy, blocking his winning lines.

The second player can only win if the opponent makes a mistake.

Varieties of tic-tac-toe

It is believed that tic-tac-toe gave rise to many other, more complex and interesting board games. But this game itself has complicated options.

For example, "volumetric" tic-tac-toe. Such a game was present on the old Atari 2600 game console. Four planes measuring 4 x 4 cells are located one below the other. A winning situation of four crosses or zeroes can be created not only on one plane, but also on all four, and there are many options: for example, each cross or zero has the same coordinate on each plane, and this is considered a win.

Gomoku, or Renju, is a Japanese game played on large fields. In competitions, this field is 15 by 15 or 19 by 19 cells, but there are options on the "endless" field. Moves are made not into cells, but at the intersection of lines; instead of crosses and zeros, checkers of black and white flowers, but the essence of the game is still the same. The winner is the one who puts five of his checkers in a row.

Hello readers of my blog, today I will tell you how to win at tic-tac-toe.

A wonderful game that does not require much preparation, we found a pen or pencil, a piece of paper and a partner.

In fact, the game is simple and, at the same time, difficult. Many do not take it seriously, so they lose. To be honest, I myself did not understand how to play it, but then I analyzed all the possible moves and realized that everything here depends on mathematics.

Why is this game so easy? The thing is that there are only 9 cells here, that is, you have 1 of 9 initial options, and then this number decreases by 1. That is, if you made your move, then your opponent already has not 9 options, but only 8, because 1 cell is already occupied.

Well, I think you understood this even without me, today I’m like “Captain Obvious”. Why is it difficult, because there are possible combinations here, and if you want to learn how to win in this game, then you will need a pen, as well as a clean sheet.

How to win at tic tac toe

Basic concepts to know:

Field- a conditional field of 3 × 3 cells, where the battle takes place.

crosses- these are the “x” icons, they go first.

Toe- these are the “0” icons, they go second.

Victory- when a player collects 3 crosses or 3 zeros in a row.

Here is an example field.

In order for you to analyze correctly, let's number each cell.

Here at least so that you understand where which field is.

3×3 winning strategy

Remember that if you play for zeros, that is, you need to make a second move, then against a strong opponent you will only make a draw. It is difficult to win with zeroes, as they move second and, practically, always defend themselves from the threats that crosses create (they move first).

Don't be surprised by what I write, as for beginners, I want you to understand how to win correctly for crosses and how to draw for zeros.

Let's start…

The best strategy. The crosses make a move to the 5th cell, which is in the middle.

Further, REMEMBER that if the zeroes make their second move not on a DIAGONAL CAGE, then they lose. It doesn't matter which cell, they make a move: 2, 4, 6, 8, if they put a zero on any of these fields, then they lose by force.

For example, you bet on 5, they bet on 2, now you bet on 1 or 3, threatening to make 3 crosses diagonally. Well, ok, you bet on 1, it turns out that if you put a cross on the field 9, you will win. You force a zero on square 9, but now you win gracefully by putting a cross on square 7.

It turns out that you threaten to put three crosses diagonally with move 3 and vertically with move - 4. Beauty, isn't it?

The best defense for zeros is, after going 5 for crosses, to make moves: 1, 3, 7, 9, in this case, if you are careful, you will always make a draw. Remember this simple rule and you will never lose.

Cunning strategy for crosses

But, after all, the player is not at all obliged to make the first move to the middle, that is, to the cell - 5. Here, there is a very cool trap, you make the first move to the corner field.

The best defense here is to occupy the field with zeroes - 5, since it is free, then it needs to be occupied. In this case, zeros will always make a draw, by constantly threatening to put three in a row themselves.

If, for example, the crosses make a move to the cell - 1, then it will be a mistake to make a move - 4 and 9, in these cases, the crosses win by force.

Let's explore these options:

A) crosses- 1, zeros - 4, crosses - 5, zeros - 9 (forced), crosses - 3 with a win on fields 2 or 7, depending on the answer of the zeros.

C) Crosses - 1, zeros - 9, crosses - 3, zeros - 2 (forced), crosses - 7 with a win on fields 4 or 5, depending on the answer of the zeros.

Well, that's all, friends, I hope that now you know how to win tic-tac-toe 3x3. There is nothing complicated in it (the game), with the right defense, there will always be a draw, but, as you can see, there are interesting options, in which you can catch zeroes.

I wish you victories, if I forgot to write something, then remind me, you can even in the comments.

Good luck everyone, bye!

Sincerely, Yuri Vatsenko!

Loading...