Goals
The purpose of the assignment is to learn to
- Create the Tic-Tac-Toe game using Bridges
- Use a 2D array as a datastructure of values.
- Review topics from COMP51
Starter File
tic_tac_toe_scaffold.cpp
download
Please read the comments in the file very carefully and do not forget to add your Bridges credentials in the main function. If you are using Replit and started a new project don't forget to setup Bridges again
Programming part
For this project you are going to create the Tic-Tac-Toe game in C++ using Bridges. If you do not know how to play Tic-Tac-Toe, check the following for the ruleshttps://en.wikipedia.org/wiki/Tic-tac-toe(Links to an external site.).
The game board can be simulated with a two dimensional array. The player chooses a square by selecting its number. Play then alternates between the players. When someone makes a move that wins the game, play stops. If all nine squares have been taken and no one has won - the game is a draw.
Tasks
- Initialize a 3x3 empty board to
Bridges
- Display numbers on each square from 1 in the top left to 9 in the bottom right.
- Take user input from the console about the location of their next move (1-9).
- Validate the user input is inside boundaries, is an integer, and is a valid space.
- Place the users mark on the space.
- Check for a win condition with 3 in a row of the same mark.
- Go to the next player and repeat from taking user input.
Setup
To start simple initialize a grid which is 3 by 3. Display the numbers 1- in the grid like the following.
1 | 2 | 3
-----------
4 | 5 | 7
-----------
7 | 8 | 9
User Input
Take an integer input from the user that matches the above grid (1-9). If the input is invalid display a message to the player and skip their turn. Otherwise place a mark on the position the player specified. Use a different mark/color for each player.
What to hand in:
You should submit your c++ file as well as a link to the game board created on bridges
Previous Module:
Day7: June 22" style="float: left;">
Previous