Lab04 - Tic-Tac-Toe

Due: Tue, Mar 8, 2022 at 11:59 PM to Github Classroom Assignment

Requirements

  1. You will write a C program called lab04 and provide a Makefile to implement a rudimentary Tic-Tac-Toe game
  2. Your program will accept input from the command line specifying Row and Column inputs to the Tic-Tac-Toe board. 0 0 is the upper left and 2 2 is the lower right.
  3. Your program will identify win and draw patterns on the board.

Given

  1. In lecture we will discuss the basics of the game, including alternating turns, making legal moves, and detecting a win.
  2. We will learn several new C language features, including two-dimensional arrays, typedef, C library functions to accept input while your program is running.

Example Output

$ ./lab04 ? ? ? ? ? ? ? ? ?
? | ? | ?
--+---+--
? | ? | ?
--+---+--
? | ? | ?

$ ./lab04 X X X X O X O X O
X | X | X
--+---+--
X | O | X
--+---+--
O | X | O
X wins

$ ./lab04 X O X O X O O X O
X | O | X
--+---+--
O | X | O
--+---+--
O | X | O
draw

Rubric

  1. 80 pts: Print the board correctly based on input (automated test)
  2. 90 pts: Also detect horizontal and vertical wins (automated test)
  3. 100 pts: Also detect diagonal wins and draws (automated test)
  4. 101 pts: run the program in a loop, accepting alternating X and O turns until the game is over. You must also detect illegal moves. (manual test)