The goal of the Tic Tac Toe project is to make a Tic Tac Toe game that
you can play in your Codespace, similar to the way Twenty Questions
worked. You will print the board using
System.out.println
and read input from the user via
java.util.Scanner
(check out your Twenty Questions project
for some useful bits of code.) You may also find the method
Integer.parseInt
useful—it takes a
String
containing digits and returns and int
.
Thus Integer.parseInt("1234")
would return the
int
value 1234
If you finish the basics, there are two next steps you can persue: AI player or Ultimate Tic Tac Toe.
For an AI you can write code to play one of the players (or both, I suppose). Start simple, such as a computer player that just plays and random empty squares. Then you can write one that uses a heuristic such as picking the corners and the center when available. That will play okay but not perfectly. If you really want to go to town, you can write an algorithm that explores the tree of possible moves to find the best move.
Ultimate Tic Tac Toe is a variant of Tic Tac Toe where the game is played on a large board with each square containing a smaller Tic Tac Toe board. Players play simultaneously on the big board and on the nine smaller boards, claiming squares on the big board by winning the small boards. Wikipedia has a good synopsis of the rules.
Because of the more complex board and rules about when a certain small board must be played on and when the player to move gets a free choice the UI for Ultimate Tic Tac Toe is more complex but it should be possible to make a reasonable UI even in a text-based environment.
Note that writing Ultimate Tic Tac Toe is an excellent chance to see if you've made a good TicTacToe class, because an obvious way to manage the small boards is to make nine instances of your TicTacToe class to represent each of the small boards. Though some things are different, insofar as players don't necessarily alternate moves on a given small board, leading to states that could never arise in a regular Tic Tac Toe game.