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

  Implement key exchange using the diffie-hellman algorithm

Implement key exchange using the Diffie-Hellman algorithm, when peer- to-peer connections are made between bots and achieve confidentiality through encryption of the client-server commu- nications with an appropriate block or stream cipher.

  Turn the turtle image into a .gif picture

How can you turn the turtle image into a .gif picture when using the built-in turtle for Python? If that's impossible how do you remove the line when you move the turtle around?

  Discuss and research pythons dictionary data type

Research Python's dictionary data type (dict). Discuss its interface and usage.

  Write a program that has a conversation with the user

Assignment - Write a program that has a conversation with the user. The program must ask for both strings and numbers as input

  Implement key exchange using the diffie-hellman algorithm

Implement key exchange using the Diffie-Hellman algorithm, when peer-to-peer connections are made between bots. Achieve con dentiality through encryption of the client-server communications with an appropriate block or stream cipher

  Implement a program in python that given names of students

Implement a program in Python that, given 500 names of students and 500 integers in the range (0,100) representing the scores of these 500 students, calculates

  Design a program that creates an object of the class

Design a program that creates an object of the class and prompts the user to enter the name, type, and age of his pet.

  Write a short program in python and view the output

How do you write a short program in Python and view the output, you want it to: Take two integers from the user. Save the lower number as x.

  Write a python code in R for Bayesian distance clustering

Write a python code in R for Bayesian distance clustering. The python code is available but has a few errors. R coding Bayesian modeling Multivariate Data

  TDS2101 Introduction to Data Science Assignment

TDS2101 Introduction to Data Science Assignment Help and Solution, Multimedia University, Malaysia - Assessment Writing Service.

  Create a program in python that analyzes twitter information

CS1026: Write a complete program in Python that analyzes twitter information. With the emergence of Internet companies such as Google, Facebook and Twitter.

  Write a python program that asks user to input a integer

Write a Python program that asks user to input a positive integer n and prints out certain numbers.

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