-2

I made a Tic Tac Toe (10x10 board size) bot. It plays better than an average human.

The board size is 10x10 instead of 3x3. 5 in a row O's or X's must be placed to win, instead of 3.

So, I made that bot using Minimax + Board Evaluation Function + Limited Available Moves to improve performance.

Let me explain my code.

First, I used Minimax algorithm alone but realized that. There are around 100 possible states after making first move, 100*99 after making second move, 100*99*98 after making 3rd move.

And it is probably impossible to count all possible board states.

So, What I did was created a board evaluation function.

I set some rules for board evaluation function, and it is same, no matter how many games the Bot play.

But I want to make a board evaluation function, that improves itself or give me some data, that I can use it to improve it. I cannot think of any way in Tic Tac Toe, can you guys?

Thanks

CIPU
  • 65
  • 1
  • 9
  • 1
    Welcome to StackOverflow. Please read and follow the posting guidelines in the help documentation, as suggested when you created this account. [On topic](http://stackoverflow.com/help/on-topic), [how to ask](http://stackoverflow.com/help/how-to-ask), and [... the perfect question](https://codeblog.jonskeet.uk/2010/08/29/writing-the-perfect-question/) apply here. StackOverflow is not a design, coding, research, or tutorial service. – Prune Aug 20 '18 at 19:56
  • 1
    If you Google the phrase "Go-Moku", you’ll find resources that can explain it much better than we can in an answer here. – Prune Aug 20 '18 at 19:56

1 Answers1

2

One method of doing this would be to generate statistics on board states. Create a board hash function that's 1:1 with effective board states, and populate a dictionary of moves taken. Record wins/losses for each move in each board state, and apply a weight to the move selection based on the win% of a given option.

This is memory intensive, but you can improve that by a factor of 8 by using a hash that's invariant on board rotation and mirroring (trivially, you could hash all 8 rotations and flips of the current state, and always return the minimum, for example; there might be a less brute force option.)

An additional improvement is to not record moves for any games which you are guaranteed to win/lose in your look ahead window, though that's a smaller percentage improvement.

Byrel Mitchell
  • 129
  • 1
  • 7
  • I don't know exactly how many board states, but there are at least, more than 10^20 board states, and how many board states move, can I store at max? 100k? If I use a database, which I don't want to, then also I can still store limited available board states, maybe 1 billion? Remember, I need to make a move within a few seconds, otherwise, it will be boring to play. – CIPU Aug 25 '18 at 14:12
  • And what do you mean by "hash function", sorry, but I am newbie. – CIPU Aug 25 '18 at 14:19
  • Sorry for the very late response. A hash function is any function that returns a unique value for any board state. It provides fast lookups through the dictionary of states. So far as scalability, the board state probability distribution is almost certainly Pareto or similar, so 90% of the gain can be had in learning a small fraction of the board space. Try characterizing the most frequent positions (possibly by percentage of board filled? Most games will end before 40% I imagine.) and only store stats that meet those rubrics. – Byrel Mitchell Sep 06 '18 at 15:31