http___bg.itsmygame.org_1000035455_tic-tac-toe_online-game.html_1.xml
1.1 3.1 4.1 4.2 4.3 4.4 4.5 5.1 6.1 7.1 8.1 9.1 10.1 11.1 12.1 13.1 14.1 14.2
Играй играта Tic-Tac-Toe Online: Game Описание Tic-Tac-Toe Ние всички сме свикнали да виждаме по обичайния дизайн на игра Тик-так-палеца, но това просто да ви закара в ступор. Два вида смешно mordashek ще участват в турнира и всеки от тях иска да бъде победител. Започнете вашия ход и се надявам, че ще бъде в състояние да победи съперника си. Ако чудо не се случи все пак, не се отчайвайте, точно преди края на това, което той иска. Играй играта Tic-Tac-Toe онлайн. Технически характеристики на играта Tic-Tac-Toe - Game Tic-Tac-Toe на добавяне: 25.03.2015 - Размер на играта: 1.76 MB - Играта се играе: 1016 пъти - Оценка: 4.33 навън 5 (6 оценка) Игри като играта Tic-Tac-Toe За изтегляне на игри Tic-Tac-Toe Връзка за изтегляне на играта:ИЗТЕГЛЯНЕ Постави играта Tic-Tac-Toe на вашия сайт: За поставяне на игра Tic-Tac-Toe на вашия сайт, копирайте кода и поставете в HTML кода на сайта си. Също така, ако ви харесва играта Tic-Tac-Toe, копие и да го изпратите на приятел или на всичките си приятели, споделят игра със света!
1.1 1.2 1.3 2.1 2.2 3.1 3.2 4.1 4.2 4.3 5.1 6.1 7.1 8.1 9.1 10.1 11.1 12.1 13.1 14.1 15.1 15.2 16.1 17.1 18.1 19.1 20.1 20.2 21.1 22.1 23.1 24.1 24.2 24.3 25.1 25.2 26.1 27.1 28.1 29.1 30.1 31.1 32.1 33.1 34.1 35.1 36.1 37.1 38.1 39.1 40.1 41.1 42.1 43.1 44.1 45.1 46.1 46.2 47.1 48.1 54.1 60.1 61.1 62.1 63.1 64.1 65.1 65.2 66.1 67.1 68.1 69.1 70.1 70.2 71.1 73.1 74.1 75.1 76.1 78.1 79.1 80.1 81.1 81.2 82.1 83.1 84.1 85.1 86.1 87.1 88.1 89.1 90.1 95.1 97.1 98.1 102.1 103.1 104.1 105.1 105.2 106.1 107.1 108.1 109.1 110.1 111.1 112.1 114.1 116.1 117.1 118.1 119.1 120.1 121.1 122.1 126.1 127.1 127.2 128.1 129.1 130.1 131.1 132.1 133.1 134.1 135.1 136.1 137.1 138.1 139.1 140.1 141.1 142.1 143.1 144.1 145.1
Do you know how AI for Chess or Checkers work? If not - here is an exercise just for you! Though we are going to use simpler game of Tic-Tac-Toe to demonstrate the algorithm. We hope you are familiar with Tic-Tac-Toe game - otherwise you may want to try this problem first. We also have a problem about playing Connect Four game which also relies on "minimax". So, how should program play the game like Chess or Tic-Tac-Toe (e.g. the game with "full information")? The core idea is similar to how the human (grandmaster) plays: So simple! But how to "assess" position? Let us agree that assessment is expressed as a single numeric value, with 0 meaning that neither side is doing better, positive if the first player is winning and negative if the second is winning. For game like chess good assessment function could be built simply by counting remaining pieces (i.e. white score 1 for pawn, 2.5 for knight, 3 for bishop etc and black score negative values respectively). With Tic-Tac-Toe the matter is simpler. Let us score 1 for position where Crosses have won (i.e. have three in a line) and -1 for position where Noughts have won. Is it sufficient? If we check only all possible moves for one side, we will probably fail to find good solution. For example with chess we probably will find that "best move" is to capture enemy's Knight with a Queen but we miss that on the next move the opponent can recapture our Queen with a pawn. For Tic-Tac-Toe it is quite possible that single move does not lead to win so we get 0-s for every move and have no idea what to choose. So we shoud go recursive. Really, let us for every move of ours then check every possible response of the opponent. Suppose that opponent will choose the best continuation for him (and the worst for us). We can continue such recursive search for any number of moves in depth. However for chess usually we limit this depth (otherwise it will be endless search) - while in Tic-Tac-Toe we really can explore every variant to the end. So that is how the algorithm should look in pseudocode: # 'side' is either 1 or -1 (for 1-st and 2-nd player respectively) function assess(side): if some side have won: return this side endif bestMove = null bestValue = -1000000 for each (move from allPossibleMoves): makeMove(move) value = assess(-side) takeBack(move) if value * side > bestValue: bestValue = value * side bestMove = move endif endfor return bestValue * side We leave it up to you to understand how it works in details (according to explanations above) and implement it yourself for Tic-Tac-Toe game. You will be given several positions in Tic-Tac-Toe game (defined by the sequence of first moves) - and you are to calculate assessments for every possible move. We will mark moves with cell indices in range 0..8 of the cells as in this diagram: 3 | 4 | 5 (cell_index = Y * 3 + X) So that sequence of moves 4 0 2 for example means that firstly X-s is put into central cell, then O goes into upper-left corner and next X - into the upper right corner. We agree that X-s always start the game. Input data will contain the number of test-cases in the first line. Next lines will contain sequences of moves for each test case (starting from the empty board each time). Answer should tell for each position the assessments of moves to every of 9 cells. Assessments should be expressed as digits 1 or Of them 2 means that side to move (either X or will win if it puts its mark to given cell, 1 means that draw could be secured and 0 means that either this cell is already not-empty, or move to it allows the opponent to win the game. Digits should be written without spaces, e.g. 010102000 means that move to cell 1 or 3 leads to draw and move to cell 5 leads to victory. Of course phrases "side will win", "side will secure a draw" or "opponent will win" assume that both sides make further moves in optimal way. Example: input data: answer: Let us analyse these cases. 1-st case: Now it is the move for Obviously if they will not take the central cell ( # 4) the crosses then can win on the very next move. That is why assessment for every cell except 4 is But if Noughts will go this way, the crossess are forced to go to cell 0 and the noughts make a fork putting their mark into cell 2, thus gaining a victory. 2-nd case: 0 X X Here we simply have just 3 possible moves - and after any of them neither of sides can win - really we have to put two more X-s and one more O - but there is no way to put them so any of them make a line of three. 3-rd case: Now X-s are to move. If they go to cell 0, then opponent takes center with a fork, so it is a way to lose the game. Putting the mark into cell 4 makes immediate win, while going to 6 or 8 leaves the fork against noughts, so all these moves win. At last, if we put X to cell 5 then O-s will take the center and the rest of the game is forced ( X to 6, then O to 8 and X to 0) making a draw.