CMSC 201 – Computer Science I for Majors Page 1 Project 1 – Tic-Tac-ToeAssignment: Project 1 – Tic-Tac-Toe 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!Remember to enable Python 3 before you run your programs:scl enable python33 bashInstructionsFor 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.A very important piece of following the coding standards is writing a complete file header comment block. Make sure that your file has a comment block at the top (see the coding standards document for an example).NOTE: Your filename for this project must be proj1.pyNOTE: You must use main() in your file.CMSC 201 – Computer Science I for Majors Page 2DetailsFor 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.Some additional requirements:1. The game will played by two human players – you do NOT need to worry about computer AI for this assignment.2. The person who will start will be assigned randomly. Either player 1 or player 2 may start.3. The symbol assigned to each of the players will also be random. Either player 1 or player 2 may be “O”.4. You must show a representation of the board between each player’s turn.5. During a player’s turn, you can enter the number of the square that you would like to choose, -1 to save the game, or -2 to load a game. All other choices will be rejected.6. The file that is saved should save the board, whose turn it is, and the symbol of the currently player. Use a static file named tic.txt for the save file.7. The file that is loaded should bring in the board, whose turn it is, and the symbol of the current player. Use a static file named tic.txt for the load file.8. After the winner is declared, the user should be prompted to play again.CMSC 201 – Computer Science I for Majors Page 3Random NumbersIn 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:The random.randint(X,Y) function returns a random number between X and Y (inclusive).import random # to get a random player between 1 and 2 player = random.randint(1,2) # to get a random symbol between 1 and 2 symbol = random.randint(1,2) # you will need to convert 1 and 2 to “X” and “O”Input ValidationFor 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.You will need to validate the following things: On a players turn, they can enter the numbers 1-9 (the positions on the board) or a -1 to save to the file or a -2 to load the file. If anything else is entered, the user should be prompted again. After a player has won, the user should be prompted if they would like to play again, the system should allow any version of Y/n/YES/no (including all combinations of uppercase and lowercase)We have provided additional sample output below showing how this should work in your program.CMSC 201 – Computer Science I for Majors Page 4Sample Output – General GameplayHere is some sample output of a game being played, with the user input in blue. The sample output continues on to the following page.bash-4.1$ python proj1.py Welcome to Tic-Tac-Toe This is for two players Player 2 will go first and will play with the O 1|2|3 —– 4|5|6 —– 7|8|9 Player 2 what is your choice? (1-9) or -1 to save or -2 to load: 5 1|2|3 —– 4|O|6 —– 7|8|9 Player 1 what is your choice? (1-9) or -1 to save or -2 to load: 1 X|2|3 —– 4|O|6 —– 7|8|9 Player 2 what is your choice? (1-9) or -1 to save or -2 to load: 3 X|2|O —– 4|O|6 —– 7|8|9CMSC 201 – Computer Science I for Majors Page 5Player 1 what is your choice? (1-9) or -1 to save or -2 to load: 4 X|2|O —– X|O|6 —– 7|8|9 Player 2 what is your choice? (1-9) or -1 to save or -2 to load: 7 Player 2 wins! Play again?: no Thank you for playingCMSC 201 – Computer Science I for Majors Page 6Sample Output – Input ValidationHere is some sample output that shows input validation, with the user input in blue. The sample output continues on to the following page.bash-4.1$ python proj1.py Welcome to Tic-Tac-Toe This is for two players Player 2 will go first and will play with the X 1|2|3 —– 4|5|6 —– 7|8|9 Player 2 what is your choice? (1-9) or -1 to save or -2 to load: -10 Player 2 what is your choice? (1-9) or -1 to save or -2 to load: 14 Player 2 what is your choice? (1-9) or -1 to save or -2 to load: -2 Game Loaded O|2|X —– 4|O|6 —– 7|8|9 Player 2 what is your choice? (1-9) or -1 to save or -2 to load: -1 File Saved Play again?: yes Player 1 will go first and will play with the X 1|2|3 —– 4|5|6 —– 7|8|9CMSC 201 – Computer Science I for Majors Page 7Player 1 what is your choice? (1-9) or -1 to save or -2 to load: -2 Game Loaded O|2|X —– 4|O|6 —– 7|8|9 Player 2 what is your choice? (1-9) or -1 to save or -2 to load: 1 That space is already taken. Player 2 what is your choice? (1-9) or -1 to save or -2 to load: 9 O|2|X —– 4|O|6 —– 7|8|X Player 1 what is your choice? (1-9) or -1 to save or -2 to load: 7 O|2|X —– 4|O|6 —– O|8|X Player 2 what is your choice? (1-9) or -1 to save or -2 to load: 6 Player 2 wins! Play again?: no Thank you for playingCMSC 201 – Computer Science I for Majors Page 8SubmittingOnce your Project 1 is complete, it is time to turn it in with the submit command.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% ls proj1.py linux1% █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.pyand press enter.linux1% submit cs201 PROJ1 proj1.py Submitting proj1.py…OK linux1% █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.And you’re done!
Why Work with Us
Top Quality and Well-Researched Papers
We always make sure that writers follow all your instructions precisely. You can choose your academic level: high school, college/university or professional, and we will assign a writer who has a respective degree.
Professional and Experienced Academic Writers
We have a team of professional writers with experience in academic and business writing. Many are native speakers and able to perform any task for which you need help.
Free Unlimited Revisions
If you think we missed something, send your order for a free revision. You have 10 days to submit the order for review after you have received the final document. You can do this yourself after logging into your personal account or by contacting our support.
Prompt Delivery and 100% Money-Back-Guarantee
All papers are always delivered on time. In case we need more time to master your paper, we may contact you regarding the deadline extension. In case you cannot provide us with more time, a 100% refund is guaranteed.
Original & Confidential
We use several writing tools checks to ensure that all documents you receive are free from plagiarism. Our editors carefully review all quotations in the text. We also promise maximum confidentiality in all of our services.
24/7 Customer Support
Our support agents are available 24 hours a day 7 days a week and committed to providing you with the best customer experience. Get in touch whenever you need any assistance.
Try it now!
How it works?
Follow these simple steps to get your paper done
Place your order
Fill in the order form and provide all details of your assignment.
Proceed with the payment
Choose the payment system that suits you most.
Receive the final file
Once your paper is ready, we will email it to you.
No need to work on your paper at night. Sleep tight, we will cover your back. We offer all kinds of writing services.
No matter what kind of academic paper you need and how urgent you need it, you are welcome to choose your academic level and the type of your paper at an affordable price. We take care of all your paper needs and give a 24/7 customer care support system.
Admission Essays & Business Writing Help
An admission essay is an essay or other written statement by a candidate, often a potential student enrolling in a college, university, or graduate school. You can be rest assurred that through our service we will write the best admission essay for you.
Our academic writers and editors make the necessary changes to your paper so that it is polished. We also format your document by correctly quoting the sources and creating reference lists in the formats APA, Harvard, MLA, Chicago / Turabian.
If you think your paper could be improved, you can request a review. In this case, your paper will be checked by the writer or assigned to an editor. You can use this option as many times as you see fit. This is free because we want you to be completely satisfied with the service offered.