[Solved] COMP1044 UO Programming Fundamentals Assignment Part Two

$25

File Name: COMP1044_UO_Programming_Fundamentals_Assignment_Part_Two.zip
File Size: 527.52 KB

SKU: [Solved] COMP1044 UO Programming Fundamentals Assignment Part Two Category: Tag:
5/5 - (1 vote)

Assignment

Mastermind Board Game Development

Assignment Learning Outcomes

  • Design a UML class diagram using UMLet
  • Apply object-oriented principles (encapsulation, reuse, etc.) including inheritance and composition relationships to the software design
  • Implement the software design in Python using class inheritance and polymorphism features
  • Write init functions for Python classes
  • Use stream I/O and manipulators for formatted input and output
  • Write code adhering to coding standards, guidelines and good programming practices

Instructions

The assignment will require you to design, implement, test, and debug a text-based Mastermind board game using object-oriented methods and the application of appropriate relationships between classes (inheritance, composition, association). In addition, the assignment will require you to use version control to keep track of your implementation as you progress through the assignment and to document your classes appropriately.

The assignment is split into two parts: UML Design (due: Week 5), and Implementation (due: Week 9). Part 1 of this assignment (UML Design) is to be performed individually and will be submitted via LearnOnline. Part 2 of this assignment (Implementation in Python) is to be performed individually and will be submitted via LearnOnline.

Part 2: Implementation

1. Introduction

The second part of this assignment will develop your skills by allowing you to put into practice what has been taught in classes so far on object-oriented programming in Python.

2. Task Description

Mastermind is a code-breaking game for two to four players

(https://en.wikipedia.org/wiki/Mastermind_(board_game)). The goal of the game is to discover a hidden code that consists of 4-5 code pegs.

2.1 The Board Game Original Mastermind

The board game is played using:

  • a decoding board, with a shield at one end covering a row of four large holes, and twelve (or ten, or eight, or six) additional rows containing four large holes next to a set of four small holes;
  • code pegs of six different colours (Red, Green, Blue, Cyan, Magenta, Yellow), with round heads, which will be placed in the large holes on the board; and
  • key pegs, some coloured black, some white, which are flat-headed and smaller than the code pegs; they will be placed in the small holes on the board.

The two players decide in advance how many games they will play, which must be an even number. One player becomes the codemaker, the other the codebreaker. The codemaker chooses a pattern of four code pegs. Duplicates and blanks are allowed depending on player choice, so the player could even choose four code pegs of the same colour or four blanks. In the instance that blanks are not elected to be a part of the game, the codebreaker may not use blanks in order to establish the final code. The chosen pattern is placed in the four holes covered by the shield, visible to the codemaker but not to the codebreaker.

The codebreaker tries to guess the pattern, in both order and colour, within eight to twelve turns. Each guess is made by placing a row of code pegs on the decoding board. Once placed, the codemaker provides feedback by placing from zero to four key pegs in the small holes of the row with the guess. A black key peg is placed for each code peg from the guess which is correct in both colour and position. A white key peg indicates the existence of a correct colour code peg placed in the wrong position.

If there are duplicate colours in the guess, they cannot all be awarded a key peg unless they correspond to the same number of duplicate colours in the hidden code. For example, if the hidden code is red-red-blue-blue and the player guesses red-red-red-blue, the codemaker will award two black key pegs for the two correct reds, nothing for the third red as there is not a third red in the code, and a black key peg for the blue. No indication is given of the fact that the code also includes a second blue.

Once feedback is provided, another guess is made; guesses and feedback continue to alternate until either the codebreaker guesses correctly, or twelve (or ten, or eight) incorrect guesses are made.

If the code is not guessed correctly within 12 attempts, then the code is revealed.

2.2 The Board Game Mastermind44

Mastermind44 is a variation of the original Mastermind for 4 players: https://boardgamegeek.com/boardgame/12467/mastermind44

The difference between the two versions of the game are in the length of the code, how the code is created, how feedback is provided, and the number of attempts for each player:

  • The code consists of 5 coloured pegs.
  • There are five black code counters that contain the numbers 1 to 5. They indicate the position of the code.
  • There are white code counters that contain a colour. There are 5 white code counters for each colour. They will be used to select the colour of a position in the code.
  • The code counters are placed upside down on the table so the number and the colours cannot be seen.
  • The code is created by the four players: Each player picks a black (with a number) and a white (with a colour) code counter and secretly places them with the colour and number facing to them. One black code counter will remain on the table. This indicates a blank on the position in the code as indicated by that counter.
  • One player makes a guess and then that player and the other players provide feedback with a black or white key peg (or nothing) depending on their secret black and white code counter. (Note, the player who makes a guess may put the correct coloured code peg in the correct position according to his/her secret black and white code counter. He must indicate this by a key peg in the feedback).
  • Then the next player clockwise makes a guess and receives feedback from everyone else.
  • Each player has 5 attempts.
  • The first player who receives four black key pegs wins.
  • If each player guesses 5 times and no player wins then the code is revealed.

2.3 Adaptation for Implementation:

For the implementation we will make some adaptations:

  • Both versions, the Original and Mastermind44 must be supported by the implementation.
  • No blanks are allowed for the Original Mastermind and there will be only one blank in the code for Mastermind44.
  • The Original version will use a code consisting of 4 pegs.
  • The Mastermind44 version will use a code consisting of 5 pegs.
  • The Original Mastermind version will allow 12 attempts for the code breaker and the Mastermind44 version will allow 5 attempts for each player.
  • The computer will always provide feedback for each guess automatically on the screen. No human input is required.
  • The Original Mastermind version will allow two modes: (1) With or (2) without computer support. Computer support means that the secret code is generated automatically at the start of a game.
    • Original Mastermind without computer support: There are two players, the code maker, and the code breaker. The code maker and code breaker will be selected at random by the computer. The code maker specifies manually the code and the code breaker tries to find it.
    • Original Mastermind with computer support: There is only one player, the code breaker. The computer will generate the code.
  • The secret code for Mastermind44 is generated by the computer. The computer will reveal a unique position and colour to each player individually.

In this assignment, you will design and implement a text-based Mastermind game that fulfils the specification above. Text-based does not mean ASCII art but instead will be driven by a text-based menu interface.

The aim of the assignment is to allow you to practise creating an object-oriented design and implementing it in Python using features such as class inheritance, polymorphism, and composition. The focus of the assignment is on identifying classes and applying appropriate relationships between the classes. The game should be designed in such a way that code is reused and can be extended easily, for example, with yet another version of Mastermind.

In the second part of the assignment you will need to implement the classes and methods based on your UML class diagrams.

A brief example of how the game will be played is provided below. The remainder of the section describes the requirements of the game in more detail.

Note: the following conventions will be used when illustrating the example output below:

  • A bold purple text indicates input entered by the user
  • User input surrounded by square brackets [] indicates a specific key press

Inside Visual Studio Code:

my_game = Mastermind() my_game.play()

Welcome to Mastermind!

This game has been developed by Masud Karim

For the course UO Programming Fundamentals SP1 2021

*********************************************************

Select which game you want to play?

  • Original Mastermind for 2 players
  • Original Mastermind for 1 player with Computer Support
  • Mastermind44 for 4 players
  • Mastermind44 for 4 players with Computer Support
  • Exit

*********************************************************

*Enter your choice [Press A, B, C, D, or E]*

A [ENTER]

Player 1: What is your name? Matthew [ENTER] Player 2: What is your name? Daniel [ENTER]

*********************************************************

Welcome Matthew

You are the codemaker for this game.

You need to make a Code that consists of four pegs.

Each peg can be of the colour (R)ed, (B)lue, (G)reen, (Y)ellow, (M)agenta, or (C)yan.

Make the Code by specifying four characters where each character indicates a colour as above.

For example, BYRG represents the code Blue Yellow Red Green.

You need to enter the Code twice. Asterisk character (*) is shown on the screen for each character.

[Matthew] Enter the Code to make:

****

[Matthew] Enter the Code again to make:

****

[Matthew] The Code is stored.

*********************************************************

Welcome Daniel

You are the codebreaker for this game. Matthew has made a Code for you.

You need to break the Code that consists of four pegs.

Each peg can be of the colour (R)ed, (B)lue, (G)reen, (Y)ellow, (M)agenta, or (C)yan.

Break the Code by specifying four characters where each character indicates a colour as above.

For example, BYRG represents the code Blue Yellow Red Green.

Feedback will be provided on your attempted Code.

Black peg means there is a peg in your Code with correct colour and correct order.

White peg means there is a peg in your Code with correct colour but incorrect order.

Blank space in the feedback denotes a peg in your Code with incorrect colour and incorrect order.

You will get 12 attempts to break the code.

Good luck!

[Daniel] Enter the Code to break:

GGGG

Attempt #1:

GREEN GREEN GREEN GREEN Feedback #1:

[Daniel] Enter the Code to break:

RRRR

Attempt #2:

RED RED RED RED

Feedback #2:

BLACK BLACK

[Daniel] Enter the Code to break:

BBBB

Attempt #3:

BLUE BLUE BLUE BLUE

Feedback #3:

BLACK BLACK

[Daniel] Enter the Code to break:

RRBB

Attempt #4:

RED RED BLUE BLUE

Feedback #4:

BLACK BLACK WHITE WHITE

[Daniel] Enter the Code to break:

BBRR

Attempt #5:

BLUE BLUE RED RED

Feedback #5:

BLACK BLACK WHITE WHITE

[Daniel] Enter the Code to break:

BRBR

Attempt #6:

BLUE RED BLUE RED

Feedback #6:

WHITE WHITE WHITE WHITE

[Daniel] Enter the Code to break:

RBRB

Attempt #7:

RED BLUE RED BLUE

Feedback #7:

BLACK BLACK BLACK BLACK

Congratulations Daniel! You have broken the Code in 7 attempts.

Daniel has won this original matermind game!

Better luck next time Matthew!

*********************************************************

Select which game you want to play?

  • Original Mastermind for 2 players
  • Original Mastermind for 1 player with Computer Support
  • Mastermind44 for 4 players
  • Mastermind44 for 4 players with Computer Support
  • Exit

*********************************************************

*Enter your choice [Press A, B, C, D, or E]* E

Goodbye!

3. Documentation

Your code must be documented appropriately using docstrings comments.

Document as you go, not all at the end. One strategy is to write a brief comment about what the 1 thing the function is supposed to do when you declare it, then refer to that comment while implementing it: this helps maintain focus when implementing the function and helps stop yourself from making it do more than the 1 thing it is supposed to do.

Each class and each method should have at least one docstring which can be brief. The responsibilities that you have specified in the UML diagram can be used as a starting point for the class docstring.

4. Python Code Style Guide

There are many style guides available online. Follow the Python guide available here:

https://www.python.org/dev/peps/pep0008/

5. Version Control

You must use version control to keep track of your progress during implementation, using git. You should perform regular commits as you implement features and fix errors. Your commit comments should reflect the context of the changes that were made in each commita fellow developer can always diff the contents to see exactly what changed but that does not provide the context. You should try to ensure each commit comment contains a short subject line.

Your submission will comprise your entire version control repository, so it should be specific to the assignment. For example, if you use git, you must create the git repository in the root directory for your assignment. Do not commit your assignment to a repository created in a parent folder or any other location. Your repository must contain all source files required to run your program. You can use the .gitignore file to specify files and folders you do not want to include in the repository, such as the generated documentation files/folders.

You do not have to use an online version control repository such as GitHub. If you do use an online repository, ensure that the assignment is private, i.e., cannot be seen by people other than yourself.

6. Implementation Rules and Hints

Implement your code into a single Python file.

It is recommended that you test individual methods as you go, rather than trying to test the whole application through the menu-driven interface. Writing code to test specific elements will speed up development as you will not need to constantly enter data through the menu interface.

Update the UML diagram as you implement the program and you realise that attributes or methods are missing in the design. You will need to submit an updated UML diagram with your submission.

7. Work Plan

To complete the implementation, you will need to perform the following steps:

  1. Read the assignment specification carefully.
  2. Start to implement the basic classes for the Original Mastermind with single player mode.
  3. Always include docstrings for documentation as you go. If you do this later, you may forget something, and it is more effort to insert documentation at a later stage.
  4. Create basic functionality before you start to implement the interaction with a player, for example, generating code, checking an attempt from the player, and providing feedback.
  5. Create interaction with the player.
  6. Update the UML diagram to reflect your implementation.
  7. Start testing the game: (1) Write tests for methods. (2) Play the game and try out different things.
  8. Include exception handling where necessary based on test results.
  9. Implement the two players mode for Original Mastermind.
  10. Implement Mastermind44: First basic classes, then the interaction with players.
  11. Update the UML diagram to reflect your implementation.
  12. Start testing the Mastermind44 game: (1) Write tests for methods. (2) Play the game and try out different things.
  13. Submit your assignment

4. Submission Details

You MUST submit a zip archive which contains the following files:

  • Updated UML Class Diagram as a single PNG imported into Word or PDF The file MUST be generated from the UMLet modelling tool: a photo of a hand-drawn diagram will NOT be accepted.
  • A Python file that contains the implementation of the game.
  • A Word document that explains how to start and interact with the game.
  • Version control directory (.git folder)

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[Solved] COMP1044 UO Programming Fundamentals Assignment Part Two
$25