辅导Foundations of Computing game、讲解game程序

- 首页 >> 其他


COMP10001 Foundations of Computing

Changelog

• Corrected:

it is not possible to start a build pile from the stockpile or another build pile

to:

it is not possible to start a discard pile from the stockpile or another discard pile

in the description of build piles

• Reinforcement of the fact that illegal plays to discard piles can only happen from the hand.

• Clarification of the fact that, for the Bonus Game, Jokers can complete build piles only in the role of a 2 or a King (not an Ace)

• Clarification that any play involving an embargo card is a turn-ending play

• Further clarifications of corner cases in bonus game

1 Game Description

In this project, you will implement a program that plays a game called “Comp10001-Bo”, which is a variant

of Skip-Bo.1 Why a variant? Because Tim can’t help himself ... or more seriously, because Tim wanted to

come up with a version that was more compatible with a computational implementation (e.g. not too long, and

suitably algorithmically complex).

In the standard version of the game, we will play Comp10001-Bo with two standard decks of 52 cards each (i.e.

104 cards in total). 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.

2 The Rules of Comp10001-Bo

2.1 Overview

Comp10001-Bo is a 4-player game, where the objective is to be the first to empty out the “stockpile” that you

are dealt at the start of the game.

The primary components of the game, as depicted in Figure 1, are:

• a “hand” of 1–5 cards, that is replenished at the start of each turn or when the hand is exhausted during a

turn

• a “draw pile” (face down) that players draw cards from to make up their hand

• a “stockpile” of cards (face down, except for the top card that is revealed) — one for each player — that

they are seeking to exhaust by playing the cards onto one of the build or discard piles

1

In a moment of weakness, Tim may have entertained the possibility of naming the game “Tim-Bo”, and equally may have selfvetoed

the name.

• four “build piles”, shared between the four players (face up), that are initially empty and used to build up

sequences of cards.

The only cards that can be used to start build piles are 2s and Kings (of any colour).

Cards on build piles must all be of the same colour (i.e. all red or all black, based on the colour of the

starting card for that pile), and be adjacent in value. For example, if the top card of a build pile was a 4

of Hearts, cards that could be placed on it are a 3 of Hearts or Diamonds, a 5 of Hearts or Diamonds, or

an Ace of Hearts or Diamonds (see below). It is not possible to loop around from a King to a 2 (or vice

versa) in the case of build piles.

A non-empty build pile can be “completed” by placing a 2, King or Ace of the appropriate colour on it.

In the case of an Ace, the card does not have to be adjacent in value to the card it is placed on (as the only

exception to the adjacent value rule). Immediately on completion, build piles are cleared from the table

and shuffled into the draw pile.

• four “discard piles” per player (16 in total; face up) that are initially empty and used to discard cards from

the hand and stockpile, as well as to move (single) cards around between discard piles.

A discard pile can be started with any card other than an Ace by the owning player (it is not possible

to start the discard pile of any other player), by playing any card from the player’s hand onto the empty

discard pile. Note that it is not possible for a player to start the discard pile of another player, and equally

it is not possible to start a discard pile from the stockpile or another discard pile. Starting a new discard

pile automatically ends the player’s turn (see below).

Once a discard pile has been started any player may discard cards onto it, from their hand, stockpile or

the top card from other discard piles. Cards on discard piles must alternate in colour (between red and

black), with adjacent cards being adjacent in value, including the possibility of looping around from a

King to a 2 or vice versa (unlike build piles). For example, if the top card is a Jack of Clubs (value =

11, colour = black), cards that can be placed on it are the 10 of Hearts or Diamonds (value = 10, colour

= red), or Queen of Hearts or Diamonds (value = 12, colour = red). Note that Aces cannot be played on

discard piles under any circumstances.

In addition to starting a new discard pile, it is possible to “restart” a non-empty discard pile of any player

by illegally placing a (non-Ace) card on top of the discard pile from the hand (and only the hand). An

“illegal” placement is simply one which does not follow the rule that adjacent cards must alternate in

colour and be adjacent in value. Starting a new discard pile or “restarting” a discard pile ends the player’s

turn, whereas if a player places a card from their hand, stockpile or another discard pile (of their own or

another player) onto a non-empty discard pile counts as a single play but does not automatically end the

player’s turn (see below).

Note that the values of cards within either a discard pile or a build pile may alternate in direction (i.e. they do

not have to be monotonically increasing or decreasing). For example, if a 3 is placed on a 2, a 2 can then be

placed on the 3.

A single turn proceeds as follows. First, the player draws cards from the draw pile to make their hand up to 5

cards. They can then make any of the following plays, with up to 5 plays allowed within a single turn:

• (legally) play a card from their hand (i.e. alternating in colour and adjacent in value), their stockpile, or

the top card from a discard pile of any player onto a non-empty discard pile of any player; in the case of

taking a card from a discard pile and playing it to a discard pile, the destination cannot be the original

discard pile (i.e. it must move between piles)

• play a card from their hand, the top card from the discard pile of any player, or the top card from their

stockpile (players can only play from their own stockpile) onto a build pile

In the instance that the draw pile is exhausted, play continues based on the current composition of cards in each

player’s hand until no player can play any card, in which case, the game is abandoned.

Any of the following terminate a player’s turn:

1. placing a card from their hand onto one of their empty discard piles;

draw

pile

four build piles

four discard piles

handstockpile

Figure 1: An overview of the key components of Comp10001-Bo

2. illegally discarding a card from their hand onto any non-empty discard pile, violating the sequence of

value/colour, e.g. by placing a 2 of Spades onto a discard pile with a top card of 4 of Hearts (sequence

not followed) or 3 of Clubs (alternating colour not followed);

3. completing 5 (legal) plays;

4. being unable to make any more plays (through not holding any cards in their hand and the draw pile being

empty, and there being no legal moves between discard piles, or from a discard pile/stockpile to a build

pile);

5. emptying out their stockpile, in which case that player wins the game.

Note that a player must complete at least one play per turn if there is a legal play they can make. The only

context where a turn can consist of no plays is where the hand is empty at the start of the turn (because the draw

pile is empty), and there are no legal plays from the stockpile or any of the draw piles.

Players take it in turns to play, rotating play clockwise around the table.

2.2 Sequence of Play

The sequence of play is fixed throughout the game (based on clockwise sequence between the players). The

dealer shuffles the combined deck, deals out 8 cards to each of the 4 players face down to make up their

stockpile, and turns up the top card (the 8th card). The remainder of the cards are placed face down in the

middle of the table to form the draw pile.

2.3 The End of the Game

A game ends when: (a) a player has exhausted their stockpile; (b) the draw pile has been exhausted, and no

player can play any card; or (c) each player has completed a total of 20 turns, with no winner. In case (a), the

player who has exhausted their pile is declared the winner, and all other players are equal losers; in case (b) or

(c) all players are equal losers.

3 Bonus Version of Game

The bonus version of the game (as used in the bonus question) has the following additional elements:

• Each player is additionally dealt a single “embargo” card at the time of the deal, which is placed face

down next to their stockpile. This embargo card can be played against any of the other players (not

against the player themself) once the stockpile of the target player has been reduced to 3 cards or less

(including the top card), by playing the embargo card face up across the top of the discard piles of the

target player. An “embargoed” player cannot play any card form their hand or from a discard pile (but

can still play from the stockpile) until the embargo has been lifted, by way of playing the embargo card

to a discard or build pile. Each player has access to a single embargo card per game, and they do not have

to play the embargo card to win the game (i.e. it does not count towards their stockpile card total).

Playing an embargo card on another player, or clearing an embargo card to a discard/build pile are both

valid turn-ending plays (meaning that if no other play is possible and the turn has not ended, one of

these plays must be employed to end the turn). Note that it is not possible to embargo a player who has

already been embargoed by another player, but it is possible to re-embargo a player who was previously

embargoed by another player and cleared that embargo.

• Four Jokers are included in the pack, which function as wild cards (i.e. can take any value other than

an Ace). They can be played to any discard or build pile, including to start a build pile, but can only

complete a build pile if they could take the value of 2 or King (i.e. cannot substitute for an Ace). Their

value and colour is determined by the cards adjacent to them. For example, if a Joker is used to start a

build pile, the value is ambiguous between a 2 and a King and their colour is indeterminate, meaning that

any coloured 3 or Queen can be played on a Joker. Similarly, if a Joker is player on a 4 of Clubs on a

discard pile, it could represent either a red 3 or a red 5, and if a 6 of Spades is played on the Joker and

subsequently played to a build pile, the Joker goes back to being ambiguous in value between a 3 or 5.

Note that all plays of Jokers to discard piles are legal plays, i.e. the value is constrained to a legal value

relative to the card they are placed on top of. For example, if a Joker was played on a 5 of Clubs, and a

10 of Spades was placed on that, the 10 of Spades would be an illegal move, because there is no value

the Joker can be interpreted as taking relative to the 5 of Clubs that would make the 10 of Spades a valid

play.

For build piles, if there is an interpretation of a Joker on top of the pile as a 2 or King, the pile is

automatically cleared (e.g. if two Jokers are played on a Jack, the pile is cleared, as the top card can be

interpreted as a King).