Question: Task 1 : Displaying the Game Board In this task you will develop a program to display to the screen a text - based representation

Task 1: Displaying the Game Board
In this task you will develop a program to display to the screen a text-based representation of the state of the board mid-way through a game of Graze. Your program will take as an input argument a string of characters that represent the current state of each square of the board.
Implementation details
Board Coordinates
To facilitate in a computer-based version of Graze in a terminal environment, a set of coordinates can be setup to represent the different playing positions on the board. The board rows are represented by numbers 0,1,2,3, and columns by the letters a,b,c,d:
Using this system, player 1's first move above would be '1b', and player 2's first move would be '2c'.
Displaying the board:
You program should display the current state of the board using printf statements in the following form:
abcd
0**
1****
2****
3**
where the "abcd" indicate the board columns, "0123" indicate the board rows, and "*" represents playable/empty board positions. Any board positions that are occupied by player 1 or player 2's tokens should be indicated by the symbols "X"(for player 1) and "O"(for player 2). For example, the board position:
Would be printed to the screen as:
abcd
0*X
1*X**
2 O*OO
3 X*
Program Input
Your program should run with the following format:
./display_graze_board
where is a 12-character long string that indicates the board state, represented by numbers, where 0 represents an empty square, 1 represents one of player 1's tokens, and 2 represents one of player 2's tokens. The string should provide the characters in the order: 0b,0c,1a,1b,1c,1d,2a,2b,2c,2d,3b,3c (i.e. row-by-row, top to bottom) e.g.:
./display_graze_board 000101202002
should produce the output board:
abcd
0**
1*X*X
2 O*O*
3*O
For Task 1, you can assume that the input string will be provided without errors (i.e. automated test cases will always provide valid board state strings), however you might like to run some simple error checking within your code.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Finance Questions!