Tic tac toe

Project 1: Tic-Tac-Toe game

Create a Tic-Tac-Toe game using FIFO (named) pipes as follows. Note: Two processes (p1 and p2) must communicate via FIFO (named) pipe. If not, no credits will be given. 

  1. Create two programs that communicate via FIFO pipes.
    • p1 is for player 1 which plays with “O”.
    • p2 is for player 2 which plays with “X”.
    • You may assume p1 always plays first (for simplest’s sake in implementation).
  2. p1 and p2 run at separate terminals on the same directory.
  3. p1 and p2 are responsible for displaying the game board and interacting with each player
  4. p1 and p2 are responsible for validating inputs from the player. Input validation includes:
    • selection of the location to play (0 ~ 8)
    • validation of input data: a digit and available locations (empty cells) only.
  5. p1 and p2 communicate to find which move the other player has taken.
  6. p1 and p2 are responsible for determining game progress statuses such as playing or game over with win, loss, or tie (draw).
  7. When the game is over, p1 and p2 show if it has won, lost, or tied at its own terminal.

The game board at each terminal should be displayed as follows. Use the combination of + – | to draw the game board.

At the initial screen: Instead of zero(0), a dot(.) is displayed to avoid confusion with O (letter Oh). However, the user enters 0 (zero) to select the location.

+-+-+-+
|.|1|2|
+-+-+-+
|3|4|5|
+-+-+-+
|6|7|8|
+-+-+-+

As O/X’s have been played in some locations, digits or . are replaced by O’s and X’s. The below board shows O has placed at cell locations 0, 1, and 8 while X has played at cell locations 4 and 6.

+-+-+-+
|O|O|2|
+-+-+-+
|3|X|5|
+-+-+-+
|X|7|O|
+-+-+-+

Tags: No tags