0 votes
1 view
in AI and Deep Learning by (17.6k points)

I want to play Tic-tac-toe using an artificial neural network. My configuration for the network is as follows: For each of the 9 fields, I use 2 input neuron. So I have 18 input neurons, of course. For every field, I have 1 input neuron for a piece of Player 1 and 1 neuron for a piece of Player 2. In addition to that, I have 1 output neuron which gives an evaluation of the current board position. The higher the output value is, the better is the position for Player 1. The lower it is, the better is it for Player 2.

But my problem is: How could I code that neural network? My idea was to use an Array[1-18] for the input neurons. The values of this array are the input weights. The I would walk through the array using a loop. Whenever there is a neuron to be activated, I add the weight to the output value. So the output value is the sum of the weights of the activated input neurons:

Output = SUM(ActivatedInputNeurons)

Do you think this is a good way of programming the network? Do you have better ideas?

1 Answer

0 votes
by (38.4k points)

If you are having a data layer of 18 neurons, and an output layer of 1 neuron. That's completely fine. But, you have to provide your neural net the chance to put the inputs into the association.

For this, you would require at least one middle layer. So, I would suggest to use 9 neurons in the middle layer. Each one of these should be joined to each input neuron, and the output neuron should be connected to each intermediate. Each such link has a weight, and each neuron has an activation level.

Then, you go over all neurons, a layer at a time. The input layer is just initiated with the board state. For all additional neurons, you go over all its individual links and sum over the product of the connected neuron's activation level and the weight of the connection. Finally, you measure the activation level by implementing a sigmoid function on this sum.This is the working principle.

Now, you need to train this neural network to get more accurate results. There are many algorithms for this. Finally, you might want to change the number of neurons and layers when the output don't get satisfying fast enough.

Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...