3
$\begingroup$

I'm figuring out how to manipulate convolutional neural networks (CNN) in python and I want to apply this kind of NN to an agent player that plays tic tac toe. I know that's weird and the problem doesn't need some elaborate and complex solutions like CNN, but I'm using this environment just to learn better and compare with the training of a MLP that I implemented.

So, I'm trying to think about how to represent the board correctly as an input to the CNN. Unlike the chess board which we can think the input as 8x8x6 (8x8 as the 2d array representing the board and 6 channels which one representing the different pieces of the game), the tic tac toe is a bit more complicated for me because there are just one kind of piece. Is it possible and correct to represent the X and O as different pieces? Has anyone implemented something like this?

$\endgroup$
7
  • $\begingroup$ I have implemented this in the past for tic-tac-toe however, I do not have the code right now. But, I can't find the code I sued to generate the ground truths, it was based off the perfect tic-tac-toe implementation. Writing all those iffs is quite time consuming. If you have code to generate ground truth values then I can append my CNN implementation to this problem. $\endgroup$
    – JahKnows
    May 18, 2018 at 2:45
  • $\begingroup$ Hello @JahKnows, i've implemented a minimax player based on a static function that plays on an optimal way. Maybe with this you can help me. The code is a bit long and I would like to send you as an attachment. $\endgroup$ May 18, 2018 at 11:54
  • $\begingroup$ Hey @JahKnows, how did you choose the filters you used on your CNN? $\endgroup$ May 20, 2018 at 23:17
  • $\begingroup$ @Matteus Prandini, tuning hyper-parameters is always tough. In deep learning you want to have enough filters such that the function your network is approximating is sufficiently captured, but not so complex that you need huge (maybe unavailable) amounts of data to train it. I tend to start with 32 or 64 filters. $\endgroup$
    – JahKnows
    May 21, 2018 at 2:00
  • $\begingroup$ @Matteus Prandini, if you can use your algorithm to produce a .csv file with the each row being an instance, and the column the board positions left to right and top to bottom (9 columns) and the tenth column who's turn it is, and the 11th column the position that should be played. From that dataset we can train this network. $\endgroup$
    – JahKnows
    May 21, 2018 at 2:02

1 Answer 1

2
$\begingroup$

I used a tic tac toe board to explain the value of convolutions in my master's thesis (https://apps.dtic.mil/dtic/tr/fulltext/u2/1046500.pdf checkout page 21-23 if you are interested). I think this illustration (extracted from my thesis) might answer the question on how you could represent the board to the CNN and what you hope your filters might learn through training. Presumably you could train the network to recognize playable spaces and predict best X/O placement as you add more layers to your network. While this doesn't tell you how to do this, I think my diagram will be useful in developing what type of input you should provide your network and some of the dimensions in order to answer your question.Introduction to the convolution with Tic-Tac-Toe

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.