Python代写 | COMP 1046 Object-Oriented Programming


COMP 1046
Object-Oriented Programming
Assignment Part 2

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. 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
additional rows containing four large holes next to a set of four small holes;
• code pegs of six different colours (Red, Green, Blue, Yellow, White, Black), 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 white-white-black-black and the player guesses white-white-white-black, the codemaker will
award two black key pegs for the two correct whites, nothing for the third white as there is not a
third white in the code, and a black key peg for the black. No indication is given of the fact that the
code also includes a second black.
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:
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.


本网站支持淘宝 支付宝 微信支付  paypal等等交易。如果不放心可以用淘宝交易!

E-mail: [email protected]  微信:itcsdx