CPU not playing sometimes (tic tac toe)
When playing against cpu, sometimes they don't make a move. I've checked every thing, maybe a fresh pair of eyes will help, or a completely different approach altogether.
If you want to see the error, 2,1, 2,2, anything; normally causes it, but other things do as well I just noticed this one specifically.
Please help if you can!!
new version using 2d array (still have same issue)
That's some really verbose code you have there...
Try to put it inside a 2d array, it'll make things easier:
[ [a1, a2, ...], [b1, b2, ...], [c1, c2, ...] ]
b1,... are all
[ ["x", " ", "o"], ["o", "x", "x"], ["o", "x", "o"] ]
and it will make the ai and checking process a lot easier...
Anyways, I think the problem is that there should be more
if statements covering all the possibilities (line 211)
A 2d array has nesting of 1
is a 1d array, because if each entry represented a point, all the points would be in the same spot, there is no x or y value
in a 2d array,
[ [1,2], [3,4], [5,6] ]
and each entry was a point, we have points
(1, 2), (3, 4), and (5, 6)
which can be put in a 2 dimensional graph