Description
COMP10001 Foundations of Computing
1 Game Description
In this project, you will implement a program that plays a game called “Comp10001-Go”, which is a
variant of Sushi-Go. Why a variant? Because Tim can’t help himself … or more seriously, because Tim
wanted to come up with a version that could be played with a standard pack of cards, and was more
compatible with a computational implementation (e.g. not too long, and suitably algorithmically
complex).
We will play Comp10001-Go with one standard pack of 52 cards. Each card has a “suit” (Spades,
Clubs, Hearts, Diamonds) as well as a “value” (numbers 2 to 10, as well as Jack, Queen, King and
Ace). For the purposes of this game, Aces are considered to have value 1, Jacks 11, Queens 12 and
Kings 13. The game makes strong use of the notion of the “colour” of a card, where Spades and Clubs
are black, and Hearts and Diamonds are red.
We will refer to the cards as a two-character string, made up of the value (‘234567890JKQA’, where
‘0’ refers to a 10, ‘J’ a Jack, ‘Q’ a Queen, ‘K’ a King, and ‘A’ an Ace) and suit (‘SHDC’, indicating
Spades, Hearts, Diamonds, and Clubs, respectively). For example, ‘0C’ is the 10 of Clubs, and ‘AS’
is the Ace of Spades.
2 The Rules of Comp10001-Go
2.1 Overview
Comp10001-Go is a 4-player game, where the objective is to accumulate as many points as possible
in the final set of discarded cards.
The primary components of the game are:
• a “hand” of 1–10 cards, from which one card is selected to discard to the table each turn
• a set of 0–9 “discard” cards that have previously been discarded to the table by each player (all
of which are visible to all players)
A single turn proceeds as follows. Each player selects a single card to discard, and places it face down
in front of them. Once all players have selected their discard card, they pass the remainder of their
hand (also face down) to the player to their left, and then turn their discard card face up.
Player continues until all players have exhausted their hand (i.e. there are no more cards in the hand),
which happens after exactly 10 turns each game.
2.2 Starting a Game
At the start of a new game, the pack of 52 cards is shuffled, and each player is dealt 10 cards. The
remaining 12 cards are placed face down away from the table of play, and play no direct role in the
game.
The sequence of players is fixed throughout the game, meaning that each player will both pass their
hand to the same player to their left, and receive a new hand from the same player to their right each
turn. (based on clockwise sequence between the players).
2.3 The End of the Game
A game ends after 10 turns, at which point each player’s discards are scored as follows:
• Cards which are part of an “N-of-a-kind” (where N ≥ 2, and the cards match on value), are
scored based on the face value of the card multiplied by N! = 1 × 2 × …N. For example, a
three-of-a-kind set of fours would score 3! × 4 = 3 × 2 × 1 × 4 = 24 points, and a two-of-a-kind
set of Jacks would score 2! × 11 = 2 × 1 × 11 = 22 points. Note that all values other than aces
can form part of an N-of-a-kind, and that Aces can’t form part of an N-of-a-kind with other
cards.
• Cards which are part of a “run” of at least 3 cards of alternating colour, i.e. a sequence of N cards
of consecutive value where adjacent cards are of different colour. For example, the following
are runs of 3 and 4 cards, respectively:
– [‘2S’, ‘3D’, ‘4C’]
– [‘0C’, ‘JD’, ‘QS’, ‘KH’]
Note that runs cannot wrap around from 13 to 2, i.e. the following is not a valid run of 3 cards:
– [‘KD’, ‘2S’, ‘3D’]
Aces have special status in runs, in that they can stand in for any value from three to Queen in
filling a gap in a run. For example, the following are valid runs:
– [‘2S’, ‘AD’, ‘4C’]
– [‘0C’, ‘AH’, ‘AC’, ‘KH’]
Note that the colour of the Ace must match the alternating sequence of cards, and there must
be at least two non-Ace cards in a run. E.g. the following are not valid runs:
– [‘2S’, ‘AD’, ‘AC’] #not enough non-Aces
– [‘0C’, ‘AD’, ‘AH’, ‘KS’] #colour of second Ace doesn’t match
Note also that Aces can only fill gaps within runs, i.e. the lowest- and highest-scoring cards in
a run must be non-Aces, meaning that the following are invalid runs:
– [‘2S’, ‘3H’, ‘AC’] #Ace doesn’t fill a gap
– [‘AC’, ‘JD’, ‘AH’, ‘KS’] #aces can only fill a gap, and only one gap
Runs are scored based on the sum of the value of each card in the run; Aces are scored based
on the value of the card they stand in for. For example, the following two runs:
– [‘2S’, ‘3D’, ‘4C’]
– [‘0C’, ‘AD’, ‘AC’, ‘KH’]
would score 2 + 3 + 4 = 9 and 10 + 11 + 12 + 13, respectively.
• Any cards which are not part of an N-of-a-kind or run are considered to be “orphans”, and
score negative the value of the card, with Aces scoring −20. For example, the following sets of
orphan cards:
– [‘9S’, ‘AD’]
– [‘2C’, ‘3S’, ‘9H’, ‘JS’]
would score −9 − 20 = −29 and −2 − 3 − 9 − 11 = −25, respectively.
At the end of the game, players form their cards into groups for scoring purposes. Any card which
is not part of a larger group forms a “singleton” (i.e. a group of one), and is scored as negative the
value of that card. For example, if the discards from a player were:
[‘AH’, ‘AS’, ‘7C’, ‘7S’, ‘QS’, ‘9H’, ‘7H’, ‘4C’, ‘AC’, ‘JH’]
One possible grouping would be the following (where each list of cards signifies a group):
[[[‘7C’, ‘7S’], [‘4C’], [‘AH’, ‘AS’, ‘QS’, ‘9H’, ‘7H’, ‘AC’], [‘JH’]]]
which would score 56 points (7 × 2 − 4 + (7 + 8 + 9 + 10 + 11 + 12) − 11).
The player(s) with the highest score are the “winners”, and all remaining players are considered to
have “lost” the game.