This assignment is composed of one program, in which you'll accept an input file as a command line argument (for example: ./a.out someFileName.txt). This program will be responsible for opening the file, reading each line into a string, parsing that string, and manipulating an array based on the contents.
Given the large feature set of the program, I'd highly recommend you read the assignment description a few times and build a complete understanding of what you need to implement. Follow a top-down design approach as described in our Algorithms lecture, and write down a checklist of everything you need to do. Implement, and test each checklist item one at a time to ensure you meet every requirement of the assignment without getting overwhelmed.
Your friend has fallen in love with Webflix's hot new show: TicTacToes Gambit - and now all they talk about is TicTacToe. Inspired to compete on the world stage, theyve purchased a strategy book containing scripts of past high profile TicTacToe games in TTTNotation. Unfortunately, they cant read TTTNotation. Build a program for them that reads lines from a text file, and prints out the associated moves on a TicTacToe board. Do this, and maybe theyll share some of that sweet prize money with you.
The program should accept 1 command line argument: A relative file path.
When the program runs, it should:
1. Open the file inputted from the command line argument
2. Read one line in the file
3. Print the current state of the TicTacToe board
4. Repeat steps 2 and 3 until all lines in the file have been read
5. Close the file
6. Print the total number of moves made in the game
7. End the program
A TicTacToe board consists of 3 rows, and 3 columns, for a total of 9 squares. An empty square is represented by a period. Player x's symbols are represented by a lower case x, and player os symbols are represented by a lower case o. Each square is separated by a space character. For example, and empty board is printed as follows:
. . .
. . .
. . .
And a board in which player x has gone in the square in the first row and first column, and player o has gone in the last row and last column is printed as:
x . .
. . .
. . o
When printing multiple boards to the screen, each board should be separated by a six hyphens.
For example:
. o .
. . .
. . .
------
. o x
. . .
. . .
TTTNotation is a made up representation for moves played on a tic tac toe board. You won't find references to it on Google. Youll need to parse it following the specification in this document.
A complete TTTNotation file contains multiple lines. At the beginning of the file, assume the TicTacToe board is empty. The first line of the file, represents the first move on the TicTacToe board. The second line of the file, represents the second move. The third line represents the third move. .etc until the last line of the file, which represents the final move in that game. For example, if a file contains 5 lines - then there were five total moves made in the game. These moves are the only things present in a TTTNotation file.
Each line in the TTTNotation file is in the following format:
player,row,column
Where:
Each line is played after the previous line. So as you read more than on line, you will print the state of the board with all the moves played so far.
For example, if the following file was inputted:
x,1,1
o,2,2
x,1,2
o,3,2
x,1,3
Your program would print:
x . .
. . .
. . .
------
x . .
. o .
. . .
------
x x .
. o .
. . .
------
x x .
. o .
. o .
------
x x x
. o .
. o .
Total moves: 5
The functionality for printing the board must be written in its own function, named printBoard.
The functionality for printing the dashes to separate the boards must be written in its own function, named printDivider.
The opened file must be exactly as inputted as a command line argument. Do not make any changes to the input argument. Do not open any other file. The file must be closed before the program is ended.
A two dimensional array must be used to represent the TicTacToe board.