0

I have created a tactactoe game in Android and it is great. But this game has 3*3 game play. In 3*3 game we can implement our manual AI(Filling corner position first) or we can use Minimax algorithm to get best move. This is great for 3*3 board. But when I tried the same algorithm for 4*4 and 5*5 the algorithm is taking a huge time to determine the best move. Hence I can not use minimax algorithm.

So what can I do now? I want to implement different level with different goal like below enter image description here

Here it is 6*6 board and the goal(Consecutive symbol to win) is 5. So I want to design an ai for this dynamic board with dynamic goal.Goal can be 3,4,5 etc. How can I do that? Thanks in advance.

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
Mobile Dev
  • 315
  • 2
  • 10

1 Answers1

1

ohh boy.. I'd rather use strategies instead of actual AI paradigms on this type of game. Make a hardcore strategy, and then for lower levels of difficulty make it dumb with random moves with a p probability.

Basically your strategy is what any 5 year old would do: if the opponent is 1 or 2 steps* away from making a full line, block him. else, work on expanding one of your longest lines.

  • 1 step, if his line is closed on the other end, 2 steps if his line is open on both ends.

Of course, you might trick this strategy if you're given the opportunity to make a cross, or develop 2 lines simultaneously. But you can make a program to watch out for that too.

But if you really want to go the AI route, why not try a genetic algorithm that saves and cumulates its results (best individuals) after each game? if calibrated correctly it will run pretty fast and then all you have to do is train it like a dog a couple of rounds.

Alex Sicoe
  • 140
  • 2
  • 10
  • thanks for the reply. But I am thinking why this question got negative vote. Very strange. Want to know the cause. – Mobile Dev Aug 24 '18 at 15:23
  • this is not so easy. I have played so many tic tac game which are available in the market. Some used random moves and then try to block the user to win. If the user do any mistakes then the AI win the game. But I also saw those games where they implemented a very smart AI where the computer always try to win. Again here goal is not always same. The way you suggested I tried already. Even I have implemented maxim with difficulty. But I am not satisfied with the performance when the board size is high. – Mobile Dev Aug 24 '18 at 15:29
  • @MobileDev Any downvotes will be from people who consider this kind of question "too broad" for SO. Questions that can be seen as "I want to do X but I don't know where to start" are usually received poorly; people expect you to start on a solution, and then explain where you got stuck. – m69's been on strike for years Aug 24 '18 at 18:13
  • @m69 I already did some searching on that. So I had to explain what I found. If I do not explain then some people will think that I did not search over internet. I found so many big questions in this site. I have mentioned the main problem in the title "How to design a algorithm for bigger Tic Tac Toe game boards? " . So it is easy to understand. Now if one needs insight of this problem I think I had to clear my position. It is very cruel thing when you get this kind of attitude from the people. If you can explain that shortly then edit the question rather then giving down vote. – Mobile Dev Aug 25 '18 at 12:21
  • @m69 Yes I understood. – Mobile Dev Aug 27 '18 at 06:11