Build a naughts and crosses game

Assignment Help Python Programming
Reference no: EM133011260

CSE5APG Advanced Python Programming - La Trobe University

Build a Naughts and Crosses game

Assignment description

The Assignment 2 will test your understanding and ability to apply what you have learnt throughout the lectures.

  • Python basics
  • Data structures 
  • Function
  • OOP
  • Exception Handling

Naughts and Crosses game (aka Tic-Tac-Toe) is a well-known and very sim- ple two-player game. The game consists of a playing grid (3x3 or higher) and two players. The playing grid has a set of squares. The squares will be filled by the players. The two players are known as the Naughts player which will be detonated as "O" and the Crosses player which will be denoted as "X". The playing rules are :

ˆ The Naughts player plays with "O".
ˆ The Crosses player plays with "X".
ˆ Players take turns by placing "O" or "X" on the playing grid square.
ˆ Only one player can play at a time- either "O" or "X".

ˆ The player makes their selection by entering the location of grid square they want to go (the square they want to fill).
ˆ If any of the two players have filled a grid square, then the other player and the same player cannot filled that square.
ˆ If any player gets three of their marks ("O" or "X".) on the board in a row, column or one of the two diagonals, this player will be the winner.
ˆ When the playing grid square fills up with neither player winning, the game terminates with no winner.

Steps you must complete

Please see and run attached code: test.py. You need to convert test.py into a new code using: function, OOP and exception handling. The code should ask the user to key-in the size of playing grid (e.g., 3x3, 6x6, ..etc). For example, current grid and final should be printed using function. In addition, invalid input should be handled. You need to develop three main classes: Board, Player, GameState. Each class must be implemented and tested. It is ex- pected that your program can accept various grid sizes, so all input should be set automatically based on the gird size. You must use the same names for classes (Board, Player, GameState) and functions.

The main steps are:
1. Once you run the program, the user will be prompted with a menu.

2.The user will need to enter their choice.

3. The choice will be to either begin the game, or quit.

4. If the user enters an invalid choice, the user should be prompted appro- priately letting them choose once more.

5. The program should not end unless the user chooses otherwise.

6. If the user begins the game, the game will be terminated if one player win the game or all playing grid square have been filled up with neither player winning.

3.1 Main Menu
In the main menu, the user will be prompt with a menu consisting two choices.
ˆ Begin the game
ˆ Quit the game
This will menu will be printed out to the screen.

3.2 User enter choice
The user will enter their choice. Which will result in the following.

ˆ Begin game should prompt with The game has begun then return to the main menu.
ˆ The quit game, should break out of the loop and stop the program.

3.3 Check User Input

The users choice should be checked to see if it is valid. If not then throws a custom error.

3.4 Throw custom error if user input is invalid

Please implement a custom error. This custom error should be caught be a try catch error.

4 Overview of flow of code

5 Classes Information

The Assignment 2 will consist of developing three main classes: Board, Player, GameState.

6 The Main

Below is a detailed UML diagrams explaining how the classes are related to each other. They are for explanation purpose. You can add any parameters or functions.

6.1 Overview of class relationship

7 Board
7.1 Relationship

Board

- display board(board: list)
+ check board(board: list, gameover: bool)

7.2 Board Class

8 Player
8.1 Relationship

Player

- interaction(board: list)
+ update board(board: list, gameover: bool)

8.2 Player Class

9 GameState
9.1 Relationship

GameState

- interaction(board: list)
+ update board(board: list, gameover: bool)

9.2 GameState Class

Attachment:- Advanced Python Programming.rar

Reference no: EM133011260

Questions Cloud

What is exposure under the corporate form : John Henry has a small housecleaning business. What is his exposure under a partnership form? Do the partners share the risk?
Identify at least transactions and other variables : Identify at least four transactions and other variables which are not included in the Gross Domestic Product.
Prepare the long-term receivables section of sweet balance : The $2,400,000 note receivable is dated May 1, 2019, Prepare the long-term receivables section of Sweet's balance sheet at December 31, 2020.
Find what is the net present value of decision to produce : If the company pays tax at a rate of 20% and the opportunity cost of capital is 15%?, what is the net present value of the decision to produce
Build a naughts and crosses game : Build a Naughts and Crosses game - explaining how the classes are related to each other. They are for explanation purpose. You can add any parameters
Find what should the inventory level be when a new order : If the store insists on a 1 day(s) safety stock (assume 365-days a year), what should the inventory level be when a new order is placed?
Prepare the april journal entry for bonita company : Prepare the April 1, 2020, journal entry for Bonita Company. On April 1, 2020, Bonita Company assigns $514,300 of its accounts receivable to the Third National
Prepare amortization table showing what will be installment : How much should be your loan amount. Prepare an amortization table showing what will be your installment if you borrowed 18000
Which one is better when deposit for ten year : Bank either will return your amount with 11% compound rate annually or 11 % compound rate compounded daily. Which one is better? Why?

Reviews

Write a Review

Python Programming Questions & Answers

  Write a python program to implement the diff command

Without using the system() function to call any bash commands, write a python program that will implement a simple version of the diff command.

  Write a program for checking a circle

Write a program for checking a circle program must either print "is a circle: YES" or "is a circle: NO", appropriately.

  Prepare a python program

Prepare a Python program which evaluates how many stuck numbers there are in a range of integers. The range will be input as two command-line arguments.

  Python atm program to enter account number

Write a simple Python ATM program. Ask user to enter their account number, and print their initail balance. (Just make one up). Ask them if they wish to make deposit or withdrawal.

  Python function to calculate two roots

Write a Python function main() to calculate two roots. You must input a,b and c from keyboard, and then print two roots. Suppose the discriminant D= b2-4ac is positive.

  Design program that asks user to enter amount in python

IN Python Design a program that asks the user to enter the amount that he or she has budget in a month. A loop should then prompt the user to enter his or her expenses for the month.

  Write python program which imports three dictionaries

Write a Python program called hours.py which imports three dictionaries, and uses the data in them to calculate how many hours each person has spent in the lab.

  Write python program to create factors of numbers

Write down a python program which takes two numbers and creates the factors of both numbers and displays the greatest common factor.

  Email spam filter

Analyze the emails and predict whether the mail is a spam or not a spam - Create a training file and copy the text of several mails and spams in to it And create a test set identical to the training set but with different examples.

  Improve the readability and structural design of the code

Improve the readability and structural design of the code by improving the function names, variables, and loops, as well as whitespace. Move functions close to related functions or blocks of code related to your organised code.

  Create a simple and responsive gui

Please use primarily PHP or Python to solve the exercise and create a simple and responsive GUI, using HTML, CSS and JavaScript.Do not use a database.

  The program is to print the time

The program is to print the time in seconds that the iterative version takes, the time in seconds that the recursive version takes, and the difference between the times.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd