Re: Need some help with code [C#]
You can make an unbeatable computer opponent by following the strategy listed on Wikipedia:
https://en.wikipedia.org/wiki/Tic-tac-toe#Strategy
You can work toward that in stages. For example, you must already have a function that checks if it's a winning game. If you iterate over your free squares looking for somewhere that you can place your mark to win, you have implemented step 1. You can use the same function to block the human opponent, which implements step 2. And so on.
How you do the predictive part is up to you. Maybe have a board that you can undo your trial moves. Or keep a board running in parallel for your calculations.
I haven't looked at your code.
Please create new threads for new questions.
Please wrap code in code tags using the '#' button or enter it in your post like this: [code]...[/code].
Bookmarks