I have an assignment for school, in which I have to build a neural network that will play tic tac toe, using genetic algorithms for training. The thing is that I am clueless on how to connect the two. I need help in the design. Should use the GA to generate game boards, to serve as input for the neural network. Or, should I generate the NN weights with the GA. In both cases. I'm having a really hard time with this subject, but I find it extremely fascinating. Any help would be much appreciated. Thanks
1 Answer
this is an unusual assignment or exercise for several reasons. tic tac toe is not a complicated game, there is not a large "state space" so an optimal algorithm is possible even by eg a "relatively small" finite state machine. so even a genetic algorithm or neural network alone would be sufficient (in fact, capable of playing a perfect game) and also, from a practitioner pov, overkill. it suffices as a "toy problem" but almost even too simple to fully demonstrate these techniques. breaking down the problem into a machine learning approach aka "decomposition" is part of the art/ science of the field. here are a few relatively basic/ straightforward possibilities.
genetic algorithm alone: let the candidate solutions aka chromosomes be represented as strings with alternating moves. the fitness function evaluates who wins and if the strings represent valid moves between the two players. it will not take long to find/ enumerate all possible game sequences.
neural network alone: input is (an encoding of) the opponents move, output is the computers move. a data generator must pick valid moves by the opponent.
combination (even bigger overkill): a common scenario in NN+GA technology is for the GA to be used to generate NN architectures. the GA string determines the NN architecture. eg size and possibly connectivity of the different layers. the fitness function is the results of training/ evaluating the NN on the particular GA architecture (ie chance of the computer winning).
and of course there are many other ways to combine NNs+GAs and other ways to decompose the problem into NNs or GAs alone.