A Flash Developer Resource Site

1. ## Tic Tac Toe

I want to know about the algorithm use in tic tac toe.
I am not talking about minimax algorithm but i want to know about winner decision logic.
When we compare a specific sign of "X" or "O" by row wise, column wise or diagonal wise is it breadth first search or depth first search or any other algorithm that we used or its just a simple logic.
i have tried but not get answer every one talking about minimax.

2. There are only 8 ways to win a game, by getting 3 of the same markers in any of 3 vertical, 3 horizontal or 2 diagonal rows. That means you just need 8 if statements to check to see if the game has been won, you don't need any more complicated algorithm than that. If you're talking about a strategic algorithm for playing the game, there are plenty of resources out there and none of them are very complicated.

3. along with what northcode said in terms of the 8 ways to win you should also store 1 variable, one that will store your next winning move, and than when its the ai's turn you give it a 50/50 chance to block your winning move or move somewhere random,

id store all the moves in an array like this

var game_slots={
slot1:[0,0,0],
slot2:[0,0,0],
slot3:[0,0,0]
};

and when you make you make a move on 3,3, slot 3 would look like

var game_slots={
slot1:[0,0,0],
slot2:[0,0,0],
slot3:[0,0,1]
};

and when the ai makes a move you can store its flag as a 2 since yours is a 1 lets say it made a move on 1,1 it would look like this

var game_slots={
slot1:[2,0,0],
slot2:[0,0,0],
slot3:[0,0,1]
};

4. mornings alloy, you seem to no what you say about, can you please make the game so i can learn from you coding, thank in advance.
before you maske i think you make confused with things,

var game_slots = {slot1:[1, 2, 3], slot2:[4, 5, 6], slot3:[7, 8, 9]};
trace(game_slots.slot1[0]);

i not know how do but you gonna be mixed with yours

5. it can get confusing after a while for me, how you do alloy

PHP Code:
``` var game_slots = [["0", " ", "0"], ["X", "0", "0"], ["X", "X", "X"]];// " " = unused// "X" = x piece// "0" = 0 piece/*trace(game_slots[0]);trace(game_slots[1]);trace(game_slots[2]);trace(game_slots[0][0]);trace(game_slots[1][0]);trace(game_slots[2][0]);*/for (var i:Number = 0; i < game_slots.length; i++){    trace("Game slot " + i + " : " + game_slots[i]);    for (var j:Number = 0; j < game_slots[i].length; j++)    {        if (game_slots[i][j] == "X")        {            //trace(game_slots[i][i]);        }    }}  ```
then you have inouts to deal along too

6. here is ready tic tac toe game to "learn" from. if ya ain't afraid of moonspeak.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•

 » Home » Movies » Tutorials » Submissions » Board » Links » Reviews » Feedback » Gallery » Fonts » The Lounge » Sound Loops » Sound FX » About FK » Sitemap