My goal right now is to create a bool function which tells me if winning a tictactoe game is possible(assuming you're vs the worst possible AI.) Basically if the possibility for you to win exists(i.e. playing vs someone who's trying to lose) it should return true.
So right now my code is at step 1, I check if putting a piece at any of the 9 spots on the board will make me win. I return true if it does.
Now I want to use recursion to do the next part but I'm stuck. Here's what my function kind of looks like, the checkB function just checks if the board wins, and the copyB function just copys the array.
So right now my code basically just tells me if I can win on a given board configuration on the first move. How can I make it do more then this?
I have a function that tells me if the board is a winning combination, I called it in the function I created. it's called checkB.
The function I'm trying to make should just return true if the computer can win(i.e. if vs the worst possible player) and false if it's not possible to win(i.e. the boards full, or the only moves left can't result in a win)
Right now I can see if there's a winning single move I can make that results in a win. I want it to tell me if there's multiple moves I can make that can result in a win(again, assuming your opponent is the worst player ever/trying to lose.)
So for instance, right now if the board was "X" "None" "X" in the top row my code would return true since X can win. If the top row of the board was completely empty(i.e.) all None's it would return False, even though you can definitely win still. My function should return true if it's POSSIBLE to win(i.e. if your opponent plays terribly) but right now it's only returning if I can win on that single move.
It's hard to explain what I mean, but I want to use recursion. Basically if there's enough turns left and it's possible to win, I should return true. It's assuming your opponent is also playing, but purposely trying to lose(i.e. worst player ever.)
I see. It will still go thru the possible ways to will and check if it can be achieved by a single move. But again, I would expect it to be callable from either side--the algorithm doesn't change, so why hard code it to work for just one side?