Strategic TIC TAC TOE OVERVIEW:
This is the classic game of X's and O's where each player tries to get three of their marks in a row, column or diagonally in a grid of nine squares.
For this example, the player (you) plays against the app using your mark (X).
While you can use whatever strategy you wish during game play, the app must follow the one it is programmed to follow. I programmed it to use the following strategy:
In this particular version of the game, the player (you) allways goes first and uses the X mark to play. If the player has three X's in a row, column or diagonally then he wins. End of game.
If the player's play did not result in a win then it is the app's turn.
The app checks if all of the squares have been filled before attempting to play. If no plays are available then the game is a tie. End of game.
Otherwise, the app can make a play so...
The app will look for all winning plays and if any are available, select one at random to win the game. End of game.
If no winning play is available then continue...
The app will look to see if the player is one mark away from any winning plays and if so, block one of those plays at random by putting the app mark (O) there instead.
If the player has no winning plays to be blocked by the app then continue...
If the app finds any rows, columns or diagonals which don't contain the Player's mark then it picks an empty button from one of these to make a play with preference for the center button first, followed by any corner button then any other empty button.
What is left for App to make a play is one or more rows, columns or diagonals that have a Button containing Player's mark and either one empty button and one containing App's mark or two empty buttons.
The App chooses one of the empty buttons with a preference for the center button first, followed by any corner button then any other button.
Now play goes back to the player.
The App's strategy is shown in the procedure block below:
Most major blocks contain comments that describe their function in the app.
Project aia file is attached.