Project Due Friday, February 28 2020, 8pm

Euchre (pronounced “YOO-kur”) is a trick-taking card game popular in Michigan. It is most commonly played by four people in two partnerships with a deck of 24 cards. Partnerships accumulate points for winning tricks, and the game continues until one side reaches the maximum number of points.

In this project, you will write a simulator for a game of Euchre. You will gain experience with abstract data types, object-oriented programming, and polymorphism. While building the simulator, you will use classes, std::arraystd::vector, and C++ style strings.

This project will be autograded for correctness, comprehensiveness of your test cases, and programming style. See the style checking tutorial for the criteria and how to check your style automatically on CAEN.

You may work alone or with a partner. Please see the syllabus for partnership rules. You may not share any part of your solution outside of your partnership. This includes both code and test cases.

Authors

The original project was written by Andrew DeOrio, Fall 2013. The project was modified to use C++ style object oriented programming and the specification updated by the Fall 2015 staff.

Table of Contents

Project Roadmap

This is a big picture view of what you’ll need to do to complete this project. Most of the pieces listed here also have a corresponding section later on in the spec that goes into more detail.

  1. Learn the rules for EECS 280 Euchre

    We understand that not all students are familiar with Euchre, so a complete description of the rules for “EECS 280 Euchre” is included in this specification.

    Our step-by-step explanation of a game of “EECS 280 Euchre” can be found in a YouTube video and a Powerpoint.

    Before getting started on this project, consider playing a game of Euchre with three friends or online. It will make the spec easier to understand, and it’s a Michigan tradition!

  2. Download the Starter Code

    Use the tutorial from project 1 to get your visual debugger set up. Use this wget link https://eecs280staff.github.io/p3-euchre/starter-files.tar.gz.

    Before setting up your visual debugger, you’ll need to rename each .cpp.starter file to a .cpp file.

    $ mv Card.cpp.starter Card.cpp 

    You’ll also need to create these new files and add function stubs.

    $ touch Pack.cpp $ touch Player.cpp $ touch euchre.cpp 

    These are the executables you’ll use in this project:

    • Card_public_test.exe
    • Card_tests.exe
    • Pack_public_test.exe
    • Pack_tests.exe
    • Player_public_test.exe
    • Player_tests.exe
    • euchre.exe

    If you’re working in a partnership, set up version control for a team.

  3. Familiarize Yourself with the Code Structure

    The code structure is object-oriented, with classes representing entities in the Euchre world.

  4. Test and Implement the Basic Euchre ADTs

    You are provided interfaces for basic Euchre ADTs. Test and implement those functions.

  5. Test and Implement the Euchre Game

    Write and test a main() function with a command-line interface that plays a game of Euchre.

  6. Submit to the Autograder

    • Card.cpp
    • Card_tests.cpp
    • Pack.cpp
    • Player.cpp
    • Player_tests.cpp
    • euchre.cpp

    You do not have to submit Pack_tests.cpp to the autograder.

EECS 280 Euchre Rules

There are many variants of Euchre. Our particular version is based on a variety commonly played in Michigan with a few changes to make it feasible as a coding project.

Players

There are four players numbered 0-3. If the players sat around the table, it would look like this:

There are two teams: players 0 and 2 are partners, as are 1 and 3. Each player has left and right neighbors. For example, 1 is to the left of 0, and 3 is to the right of 0. That means 1 is 0’s left neighbor, and 3 is 0’s right neighbor.

The Cards

Euchre uses a deck of 24 playing cards, each of which has two properties: a rank and a suit. The ranks are 9, 10, JackQueenKing, and Ace, and the suits are SpadesHeartsClubs, and Diamonds. Each card is unique — there are no duplicates. Throughout this document, we sometimes refer to ranks or suits using only the first letter of their name. Farther below, we describe how to determine the ordering of the cards.

Playing the Game

At a high level, a game of Euchre involves several rounds, which are called hands. Each hand consists of the following phases.

Each hand:

  1. Setup
    1. Shuffle
    2. Deal
  2. Making Trump
    1. Round One
    2. Round Two
  3. Trick Taking
  4. Scoring

We describe each in more detail below.

Setup

Shuffle

The dealer shuffles the deck at the beginning of each hand. The algorithm you will implement for shuffling is a variant of a riffle shuffle called an “in shuffle” (https://en.wikipedia.org/wiki/In_shuffle). Cut the deck exactly in half and then interleave the two halves, starting with the second half. Thus, the card originally at position 12 goes to position 0, the one originally at position 0 goes to position 1, the one originally at position 13 goes to position 2, and so on. Do this in-shuffle process 7 times.

You will also implement an option to run the game with shuffling disabled - when this option is chosen, just reset the pack any time shuffling would be called for. This may make for easier testing and debugging.

Deal

In each hand, one player is designated as the dealer (if humans were playing the game, the one who passes out the cards). In our game, player 0 deals during the first hand. Each subsequent hand, the role of dealer moves one player to the left.

Each player receives five cards, dealt in alternating batches of 3 and

  1. That is, deal 3-2-3-2 cards then 2-3-2-3 cards, for a total of 5 cards each. The player to the left of the dealer receives the first batch, and dealing continues to the left until 8 batches have been dealt.

Four cards remain in the deck after the deal. The next card in the pack is called the upcard (it is turned face up, while the other cards are all face down). It plays a special role in the next phase. The three remaining cards are not used for the current hand.

Making Trump

During this phase, the trump suit is determined by whichever player chooses to order up.

Round One

The suit of the upcard is used to propose a trump suit whose cards become more valuable during the upcoming hand. Players are given the opportunity to order up (i.e. select the suit of the upcard to be the trump suit) or pass, starting with the player to the dealer’s left (also known as the eldest hand) and progressing once around the circle to the left. If any player orders up, the upcard’s suit becomes trump and the dealer is given the option to replace one of their cards with the upcard.

Round Two

If all players pass during the first round, there is a second round of making, again beginning with the eldest hand. The upcard’s suit is rejected and cannot be ordered up. Instead, the players may order up any suit other than the upcard’s suit. The dealer does not have the opportunity to pick up the upcard during round two.

If making reaches the dealer during the second round, a variant called screw the dealer is invoked: the dealer must order up a suit other than the rejected suit.

(Note for pro Euchre players: for simplicity, we have omitted “going alone” in this version.)

Trick Taking

Once the trump has been determined, five tricks are played. For each trick, players take turns laying down cards, and whoever played the highest card takes the trick.

During each trick, the player who plays first is called the leader. For the first trick, the eldest hand leads.

At the beginning of each trick, the leader leads a card, which affects which cards other players are allowed to play, as well as the value of each card played (see below). Each other player must follow suit (play a card with the same suit as the led card) if they are able, and otherwise may play any card (it is removed from their hand). Play moves to the left around the table, with each player playing one card.

A trick is won by the player who played the highest valued card (see below to determine comparative values). The winner of the trick leads the next one.

Scoring

The team that takes the majority of tricks receives points for that hand. If the winning team had also ordered up, they get 1 point for taking 3 or 4 tricks, and 2 points for taking all 5, which is called a march. Otherwise, they receive 2 points for taking 3, 4 or 5 tricks, which is called euchred.

Traditionally, the first side to reach 10 points wins the game. In this project, the number of points needed to win is specified when the program is run.

Value of cards

In order to determine which of two cards is better, you must pay attention to the context in which they are being compared. There are three separate contexts, which depend on whether or not a trump or led suit is present.

In the simplest case, cards are ordered by rank (A > K > Q > J > 10 > 9), with ties broken by suit (D > C > H > S).

If a trump suit is present, all trump cards are more valuable than non-trump cards. That means a 9 of the trump suit will beat an Ace of a non-trump suit. Additionally, two special cards called bowers take on different values than normal.

  • Right Bower: The Jack of the trump suit. This is the most valuable card in the game.
  • Left Bower: The Jack of the “same color” suit as trump is considered to be a trump (regardless of the suit printed on the card) and is the second most valuable card.

For example, if Diamonds is trump, the Jack of Hearts is also considered a Diamond, not a Heart. The suit of the left bower is called next, while the two suits of the opposite color are called cross suits.

If a led suit is present as well as a trump suit, the ordering is the same except that all cards of the led suit are considered more valuable than all non-trump-suit, non-led-suit cards. Note that it is possible for the trump suit and led suit to be the same.

The above shows card orderings in the possible contexts. Cards in higher rows are greater than those in lower rows. Within rows, cards farther to the left are greater. Note the right bower (blue outline) and left bower (red outline).

Euchre Simple Player strategy

Here we describe the strategy used by a Simple Player. A Simple Player will always behave in this way, but these are not rules of the game (i.e. a Human Player need not follow this strategy).

Much of the strategy for our Simple Player can be implemented using the comparison functions provided by the Card interface.

Making

In making trump, a Simple Player considers the upcard, which player dealt, and whether it is the first or second round of making trump. A more comprehensive strategy would consider the other players’ responses, but we will keep it simple.

During round one, a Simple Player considers ordering up the suit of the upcard, which would make that suit trump. They will order up if that would mean they have two or more trump face cards in their hand. Trump face cards are the right and left bowers, and Q, K, A of the trump suit, which is the suit proposed by the upcard. (A Simple Player does not consider whether they are the dealer and could gain an additional trump by picking up the upcard.)

During round two, a Simple Player considers ordering up the suit with the same color as the upcard, which would make that suit trump. They will order up if that would mean they have one or more trump face cards in their hand (the right and left bowers, and Q, K, A of the order-up suit). For example, if the upcard is a Heart and the player has the King of Diamonds in their hand, they will order up Diamonds. The Simple Player will not order up any other suit. If making reaches the dealer during the second round, we invoke screw the dealer, where the dealer is forced to order up. In the case of screw the dealer, the dealer will always order up the suit with the same color as the upcard.

Adding the Upcard and Discarding a Card

If the trump suit is ordered up during round one, the dealer picks up the upcard. The dealer then discards the lowest card in their hand, even if this is the upcard, for a final total of five cards. (Note that at this point, the trump suit is the suit of the upcard.)

Leading Tricks

When a Simple Player leads a trick, they play the highest non-trump card in their hand. If they have only trump cards, they play the highest trump card in their hand.

Playing Tricks

When playing a card, Simple Players use a simple strategy that considers only the suit that was led. A more complex strategy would also consider the cards on the table.

If a Simple Player can follow suit, they play the highest card that follows suit. Otherwise, they play the lowest card in their hand.

Code Structure

The code is structured as an object-oriented program. The C++ class mechanism is used to represent entities in the Euchre world, for example CardPack, and Player. The interfaces for these classes are defined in several header files, each representing a different Abstract Data Type. Your task is to provide the corresponding implementations in .cpp files, adding any additional helper functions to the .cpp files. Finally, you will write a main() function with a command line interface to the game.

Polymorphic Players

2020-02-23