首页
网站开发
桌面应用
管理软件
微信开发
App开发
嵌入式软件
工具软件
数据采集与分析
其他
首页
>
> 详细
代写program、代做C++编程设计
项目预算:
开发周期:
发布时间:
要求地区:
1. Deadline:
Tuesday 14th May 2024
(Feedback to be released on 4
the June 2024)
2. Weighting:
50%
3. Overview
Create a basic GUI card game using C++ with Qt and organise the game structure using OOP
methods.
Royalty-free card images will be available for you to download from the COMP282 Canvas page for
you to use in the application if you choose. These will consist of 52 PNG images of standard playing
cards.
Our game is based loosely on the hands of the classic card game, Poker. We will define the rules of
the game as follows:
1. Objective: The objective of the game is to beat a computer opponent with combinations of 5
cards (known as a Hand) worth the highest value.
2. Card Value:
a. Cards have a value of 1 to 14 and a suit chosen from Hearts (♥), Diamonds (♦),
Spades (♠) and Clubs (♣). There are 52 cards in a Deck consisting of 13 cards in
each suit. There are no other cards (such as Jokers) needed in the game, and only one
deck is used.
b. Value ranges from 1 (low Ace) through the numbered cards worth 2 – 10 then 11
(Jack), 12 (Queen), 13 (King) and 14 (high Ace). Note that the Ace can be chosen to
be worth 1 or 14 as desired to match with other held cards, this is useful for straight
hands.
c. The value of cards is used to determine the winner when hands have the same rank
(more on ranks and categories later), e.g. both players have One Pair. If the value of
the rank cards are the same, the values of the remaining cards are used, e.g.:
Player has a pair of 10s, Computer has a pair of 7s, so Player wins.
In this case both players have One Pair of the same value (10). So we determine the value of the remaining cards, which are 10 for Player (2+3+5) and 19 for Computer
(9+6+4), so Computer wins.
d. The suit is only used when determining a Flush (all cards the same suit).
e. No suit has a higher value than another. E.g. a Flush of hearts and a flush of clubs
with the same numerical cards are worth the same.
3. The rank and name of the combinations are as follows, with the highest values being
statistically less likely to occur and which automatically beats any card combination from a
lower category. E.g. any Straight Flush beats any Four-of-a-Kind:
Rank
(1=highest)
Category Example Hand Explanation
1 Straight
Flush
Flush and
Straight at the
same time.
2 Four Of A
Kind
Four cards
with the same
value – in this
example four
cards of value
5.
3 Full House
Three of one
the same value
and two of
another.
4 Flush
All cards are
the same suit –
in this example
all Diamonds.
The value and
order of the
cards does not
matter
5 Straight
All cards are in
numerical
order, suit
doesn’t matter.
6 Three Of A
Kind
Three cards
with the same
value – in this
example
Queens.
7 Two Pair
Two separate
matched pairs
of different
values, in the
example above two Jacks and
two 3s
8 One Pair
A single
matched pair
of the same
value, in the
example above
a pair of 10s.
9 Highest
Card
All cards are
different for
both players
and there is not
a straight or
flush
4. If both players have a Straight Flush the one with the highest card wins, otherwise it is a
draw.
5. If both players have Four-of-a-Kind the higher card wins, e.g. four 8s would beat four 5s. It
is not possible for both players to have the same 4 cards so the winner can always be found by
comparing these.
6. If both players have Full House the higher card of the group of three wins, e.g. three 4s and
two Queens would beat three 2s and two kings. It is not possible for both players to have three
cards of the same value so the winner can always be found by comparing these.
7. If both players have a Flush the highest card wins, in this example a Jack. If both players
have a flush and the same highest cards the next highest are compared, e.g. K, 10, 8, 7, 5
would beat K, 10, 8, 7, 3. If the cards are still same the same, e.g. both players have 10, 8, 5,
4 and 2 in different suits it’s a draw.
8. Examples of Straights are A-5, 2-6, 3-7, 4-8, 5-9, 6-10 (as example), 7-J, 8-Q, 9-K, 10-A.
Note that the Ace can be worth both 1 or 14 giving two possible straights that include it, e.g.
(A, 2, 3, 4, 5) or (10, J, Q, K, A). In all other situations the Ace is always worth 14. If both
players get a Straight the highest card of each wins, e.g. 9-Q would beat 3-7. If the high card
of both straight is the same, it’s a draw.
9. If both players have Three-of-a-Kind the higher card wins, e.g. three Jacks would beat three
8s. It is not possible for both players to have three cards of the same value so the winner can
always be found by comparing these.
10. If both players have Two Pair the highest pair wins, e.g. a pair of queens and a pair of 3s
beats a pair of 10s and a pair of 9s. If both pairs are the same for each player the highest fifth
card determines the winner, e.g. J, J, 8, 8, A beats J, J, 8, 8, 10 with deciding Ace being worth
14 not 1. A draw is possible.
11. If both players have One Pair the highest pair wins, e.g. a pair of 7s beats a pair of 2s. If the
pair is the same for each player the highest of the remaining three cards determines the
winner. A draw is possible.
12. The High Card result is determined by the highest card and continues until the last card. E.g.
Q, 8, 5, 4, 3 beats Q, 8, 5, 4, 2. A draw is possible.
5. Basic Gameplay (45 marks)
1. There should be a ‘start’ (or ‘deal’) button on the game window. When this button is clicked,
the game starts.
2. The cards are shuffled before each game.
3. For each Round, 10 cards taken from the shuffled Deck and distributed to the Player and the
Computer, making two hands with 5 cards each.
4. When a card has been used in a hand, it cannot be used again during that game (but bear in
mind the ‘advanced gameplay’ sections below).
5. Each game consists of rounds. When a new round is started but there are less than 10 cards
left in the deck, the game ends (since we cannot deal full hands to the players).
6. At the start of each round, the game window should display a representation of the player’s
hand (5 cards) and the computer’s hand (5 cards). This can be text-based, but you will get
marks for using images. Under each card, it should say the name of the card (e.g. ‘6 of
Spades’ or ‘6♠’).
7. The game should work out the categories (and therefore the rank) of each of the hands. Above
the cards, there should be a label that displays the category of the hand (e.g. ‘Full House’).
8. Based on those ranks, the game should determine who has the strongest hand. This should
also be displayed.
9. There should be a button marked ‘Next Round’ which will move the game on to the next
round. If there are no more rounds, the button should be marked ‘Finish Game’.
10. A score should be displayed and updated at the start of each round, that shows the player’s
score and the computer’s score. The scores represent the number of hands won in the game.
11. After the 5 rounds have been played, the winner should be announced (or a draw declared if
applicable), and the player should be able to play another game if they wish to.
6. Advanced gameplay (10 marks)
In rounds 1-4, allow the player to swap up to three cards from their hand with cards from the deck.
It’s up to you how to implement the interface for this (perhaps ‘Swap’ buttons, or perhaps by clicking
the card, or another method of your choosing). Don’t allow swapping in Round 5 (because in Round 5
there will be only 2 cards left in the deck). The cards that are swapped out of the player’s hand can
still remain in the game (i.e. they are replaced in the Deck at a random location).
7. Even more advanced gameplay (10 marks)
If the player swaps a card, the computer has the opportunity to swap a card from its deck too. The
computer will have to determine whether or not it is advantageous to swap a card (if the computer has
a Straight Flush hand, it won’t be worth swapping, for example, but if it has 1 pair it may want to
swap one of the other cards to attempt to improve the hand).
This can be as basic or complex as you like. A basic version may just scan a hand for groups of two,
three or four cards of the same value and swap any remaining cards to try to improve this. A more
advanced system may calculate the probabilities of getting a straight or flush hand.
6. Suggested Classes/Objects and Methods in the game
You are free to code the game as you like. But please ensure that you have classes called:
Game, Player, Card, Deck, Hand.
There are some suggested structures and methods below which you may find helpful. Game class: Consists of two Players. Once the game has been completed the winner (or a draw) is
declared. Game state is shown in a game window as text and/or graphics of cards held with buttons
for triggering methods.
Player class: A class representing a player with a name and a score of hands won. Each Player
has a Hand of five Cards. Assume that both players can see each other’s cards and the result is
based purely on getting a strong hand of cards.
Card class: Has a value and a suit (e.g. 7 of Hearts).
Methods:
Card::getValue() returns the value as an integer, (e.g. 7). Aces are always worth 14 except
when used as start of a straight.
Card::getSuit() returns the suit name as a QString, e.g. “Clubs”, “Diamonds”, “Hearts” or
“Spades”.
Card::getName() returns the card name as a QString, e.g. “Jack of Clubs”, “Two of Hearts”.
Card::getNumber() returns the card type as an integer (see the section on Hand::setHand
method to see how the system works). E.g. 9 of Diamonds would return 209.
Deck class: Consists of a complete standard pack of 52 cards with one of each value 2-10 and Jack,
Queen, King and Ace in each suit (4 * 13 cards).
Methods:
Deck::createDeck() generates a complete pack correctly as stated above in any order. Each
card is a Card object.
Deck::shuffle() randomly puts the cards in a random order, e.g. before a game begins or after
the last card is dealt.
Deck::dealCard() returns the first card in deck and continues until the entire deck has been
dealt. When the last card has been dealt the entire deck is automatically shuffled so dealing can
continue indefinitely.
Hand class: Holds five cards for a player, with methods to replace and order cards within it. Each
player has one opportunity per round of the game (in rounds 1-4) to swap up to three cards to improve
their hand. After this, the winner (or a draw) is determined.
Hand::dealHand(Deck& deck): Creates a new hand of five cards from a deck, replacing any
existing cards in the hand.
Hand::sortValue(): Sorts cards in value order from smallest to largest.
E.g., a hand with cards 8, Q, 2, A, 2 would be sorted to 2, 2, 8, Q, A, considering A as 14 when not
part of a straight.
Hand::sortGroup() : sorts the cards in a hand based on the frequency of each card's value,
placing the most frequent values first. For example, a hand containing the cards 2, 7, 7, 2, 7 would be
rearranged to 7, 7, 7, 2, 2, grouping all 7s together followed by the 2s due to the higher frequency of
7s. If there are groups of equal size, such as two pairs or two triples, the groups are ordered by the
card value in ascending order. For instance, a hand with cards 6, King, 8, 6, King (where King
represents a higher value, typically 13) would be sorted to 6, 6, King, King, 8. This is because both pairs (6s and Kings) have the same frequency, and 6 is numerically smaller than King. In cases where
no multiples are present, meaning all cards have unique values, the method defaults to sorting by
individual card values in ascending order. This functionality is achieved by calling the
`sortValue()` method, which organises cards from lowest to highest value.
Hand::getBest(): Calculates the highest value in the hand as shown above and returns, from
highest to lowest value, a four-character QString: "stfl", "four", "full", "flsh", "strt", "trio", "twop",
"pair", "high".
Hand::setHand(const QVector
& cardValues):
Sets a hand to specific cards defined in a five-element integer QVector.
The first digit (s) of each integer is the suit in alphabetical order:
1 = club, 2 = diamond, 3 = heart, 4 = spade.
The next two digits (vv) are the value of the card:
01 = Ace, 02-10 = number card, 11 = Jack, 12 = Queen, 13 = King.
These values define Card objects representing the correct card which then replaces the existing hand.
Example:
Hand::setHand({111, 311, 411, 201, 308})
defines the hand: Jack of Clubs, Jack of Hearts, Jack of Spades, Ace of Diamonds, Eight of Hearts.
For Advanced Gameplay tasks:
Hand::swapCard(const QVector
& cardIndices, Deck& deck): Replaces up to
three specified cards with the next card in the deck.
Examples:
myHand.swapCard({1, 3}, myDeck);
replaces the first and third cards in deck ‘myDeck’.
myHand.swapCard({3, 4, 5}, myDeck);
replaces the third, fourth, and fifth cards in deck ‘myDeck’.
myHand.swapCard({1, 3, 1}, myDeck);
replaces the first and third cards and ignores the duplication of the first card.
myHand.swapCard({1, 3, 4, 5}, myDeck);
replaces cards 1, 3, and 4; the fourth value is ignored.
myHand.swapCard({}, myDeck);
does nothing.
Order does not matter, e.g., myHand.swapCard({3, 4, 5}, myDeck);
is the same as myHand.swapCard({5, 3, 4}, myDeck);
软件开发、广告设计客服
QQ:99515681
邮箱:99515681@qq.com
工作时间:8:00-23:00
微信:codinghelp
热点项目
更多
代做ceng0013 design of a pro...
2024-11-13
代做mech4880 refrigeration a...
2024-11-13
代做mcd1350: media studies a...
2024-11-13
代写fint b338f (autumn 2024)...
2024-11-13
代做engd3000 design of tunab...
2024-11-13
代做n1611 financial economet...
2024-11-13
代做econ 2331: economic and ...
2024-11-13
代做cs770/870 assignment 8代...
2024-11-13
代写amath 481/581 autumn qua...
2024-11-13
代做ccc8013 the process of s...
2024-11-13
代写csit040 – modern comput...
2024-11-13
代写econ 2070: introduc2on t...
2024-11-13
代写cct260, project 2 person...
2024-11-13
热点标签
mktg2509
csci 2600
38170
lng302
csse3010
phas3226
77938
arch1162
engn4536/engn6536
acx5903
comp151101
phl245
cse12
comp9312
stat3016/6016
phas0038
comp2140
6qqmb312
xjco3011
rest0005
ematm0051
5qqmn219
lubs5062m
eee8155
cege0100
eap033
artd1109
mat246
etc3430
ecmm462
mis102
inft6800
ddes9903
comp6521
comp9517
comp3331/9331
comp4337
comp6008
comp9414
bu.231.790.81
man00150m
csb352h
math1041
eengm4100
isys1002
08
6057cem
mktg3504
mthm036
mtrx1701
mth3241
eeee3086
cmp-7038b
cmp-7000a
ints4010
econ2151
infs5710
fins5516
fin3309
fins5510
gsoe9340
math2007
math2036
soee5010
mark3088
infs3605
elec9714
comp2271
ma214
comp2211
infs3604
600426
sit254
acct3091
bbt405
msin0116
com107/com113
mark5826
sit120
comp9021
eco2101
eeen40700
cs253
ece3114
ecmm447
chns3000
math377
itd102
comp9444
comp(2041|9044)
econ0060
econ7230
mgt001371
ecs-323
cs6250
mgdi60012
mdia2012
comm221001
comm5000
ma1008
engl642
econ241
com333
math367
mis201
nbs-7041x
meek16104
econ2003
comm1190
mbas902
comp-1027
dpst1091
comp7315
eppd1033
m06
ee3025
msci231
bb113/bbs1063
fc709
comp3425
comp9417
econ42915
cb9101
math1102e
chme0017
fc307
mkt60104
5522usst
litr1-uc6201.200
ee1102
cosc2803
math39512
omp9727
int2067/int5051
bsb151
mgt253
fc021
babs2202
mis2002s
phya21
18-213
cege0012
mdia1002
math38032
mech5125
07
cisc102
mgx3110
cs240
11175
fin3020s
eco3420
ictten622
comp9727
cpt111
de114102d
mgm320h5s
bafi1019
math21112
efim20036
mn-3503
fins5568
110.807
bcpm000028
info6030
bma0092
bcpm0054
math20212
ce335
cs365
cenv6141
ftec5580
math2010
ec3450
comm1170
ecmt1010
csci-ua.0480-003
econ12-200
ib3960
ectb60h3f
cs247—assignment
tk3163
ics3u
ib3j80
comp20008
comp9334
eppd1063
acct2343
cct109
isys1055/3412
math350-real
math2014
eec180
stat141b
econ2101
msinm014/msing014/msing014b
fit2004
comp643
bu1002
cm2030
联系我们
- QQ: 9951568
© 2021
www.rj363.com
软件定制开发网!