Introduction
PIG,c++,2,
list, 2。,
Requirement
2016/17 ELEC362 - Application Development using C++ 1
Assignment 1
Program a multiplayer console game of ‘Pig’
Game Rules: (according to Wikipedia)
Each turn, a player repeatedly rolls a dice until either a 1 is rolled or the player decides to
“hold”:
• If the player rolls a 1, they score nothing and it becomes the next player’s turn.
• If the player rolls any other number, it is added to their turn total and the player’s turn
continues.
• If a player chooses to “hold”, their turn total is added to their score, and it becomes
the next player’s turn.
The first player to score 100 or more points wins.
For example, the first player, Ann, begins a turn with a roll of 5. Ann could hold and score 5
points, but chooses to roll again. Ann rolls a 2, and could hold with a turn total of 7 points, but
chooses to roll again. Ann rolls a 1, and must end her turn without scoring. The next player,
Bob, rolls the sequence 4-5-3-5-5, after which he chooses to hold, and adds his turn total of 22
points to his score.
The implementation should exercise the object-oriented design aspects and good
practices for design and implementation.
entities that must be realised as C++ classes.
attributes for each of these entities.
Identify the methods that may be useful for each of these entities.
• By carefully considering the rules of the game, implement the classes for your entities.
Pay special attention to the interaction between classes and annotate your
implementation using useful comments.
• Design you classes to be reusable for part 1 and part 2
Part one of assignment
Program a multi-player version of the game that allows a number of players to compete
against each other.
Part two of assignment
(Reusing the classes from the multiplayer game)
Develop automated players that use at least two strategies (e.g. hold after a fixed number of
throws, hold after a fixed gain of points)
Write a code that automatically runs the automated players against each other and use
statistics to compare the strategies.
2016/17 ELEC362 - Application Development using C++ 2
Submission
Please submit your report and the source code (zipped project for both parts) on VITAL.
In the report you will outline your design process by describing what classes you use, what
attributes and methods they contain and give an overview how they intact.
Please copy your source code at the end of the report. (When pasting code in Word choose
‘Past Options/Keep Source formatting’ to keep the colour coded formatting used in Visual
Studio.)