CMSC 201 Spring 2016: Project 1 - Tic-Tac-Toe
CMSC 201 Spring 2016: Project 1 - Tic-Tac-Toe
CMSC 201 Spring 2016: Project 1 - Tic-Tac-Toe
Project 1 – Tic-Tac-Toe
Assignment: Project 1 – Tic-Tac-Toe
Due Date: Monday, April 18th, 2016 by 8:59:59 PM
Value: 80 points
Project 1 is the first assignment where we won’t be telling you exactly what to
do! You will get the chance to make your own decisions about how you want
your program to handle things, what its functions should be called, and how
you want to go about designing it.
Project 1 will also be substantially longer than any of the single homework
assignments you’ve completed so far, so make sure to take the time to plan
ahead, and don’t do any “cowboy” coding!
Instructions
For this assignment, you'll need to follow the class coding standards, a
set of rules designed to make your code clear and readable. The class coding
standards are on Blackboard under “Course Documents” in a file titled
“CMSC 201 - Python Coding Standards.”
You should be commenting your code, and using constants in your
code (not magic numbers or strings). You should also have a function
header comment for every function that is not main()!
Re-read the coding standards!
You will lose major points if you do not following the 201 coding standards.
For this project, you are going to be building the classic game tic-tac-toe in
Python. In this game, one player is X and the other player is O. Players take
turns placing their X or O. If a player gets three of their marks on the board in
a row, column or one of the two diagonals, they win. When the board fills up
with neither player winning, the game ends in a draw.
In order to choose the starting player and symbol, you are required to
randomize who goes first and which symbol they will start with. In Python this
is easy to do if we import the random library. The code below shows exactly
how to do this:
import random
Input Validation
For this project, we will require that you validate input from the user. You can
assume that the user will enter the right type of input, but not that they will
enter a correct value. In other words, a user will always give an integer when
you expect one, but it may be a negative or otherwise invalid value.
We have provided additional sample output below showing how this should
work in your program.
Here is some sample output of a game being played, with the user input in
blue. The sample output continues on to the following page.
Here is some sample output that shows input validation, with the user input
in blue. The sample output continues on to the following page.
O|2|X
-----
4|O|6
-----
7|8|X
Don’t forget to complete the header block comment for your file! Make sure
that you updated the header block’s file name and description.
You must be logged into your GL account, and you must be in the same
directory as the Project 1 file. To double check this, you can type ls.
linux1[3]% ls
proj1.py
linux1[4]% █
To submit your files, we use the submit command, where the class is
cs201, and the assignment is PROJ1. Type in (all on one line)
submit cs201 PROJ1 proj1.py
and press enter.
If you don’t get a confirmation like the one above, check that you have not
made any typos or errors in the command.
You can double-check that your file was submitted by using the submitls
command. Type in submitls cs201 PROJ1 and hit enter.