Video poker ♥ ♣ ♠ ♦

Implement a program that runs a game of video poker.

Poker is a popular card game that comes in many forms: draw, stud, Texas Hold’em, and many more. Typically, poker is played by multiple players, betting against each other.

Video poker is a popular single player casino game based on 5-card draw poker.

The game works like this:

  1. The player places a bet.
  2. The player receives a hand of 5 cards.
  3. The player chooses any number of cards to hold.
  4. Unheld cards are replaced by newly dealt cards.
  5. The final hand is scored and the player wins or loses their bet, based on the game’s pay table.

Poker hands

Poker hands are ranked by the relative rarity of the combinations. The order is as follows (best to worst):

Payout table

There are many possible payout tables for video poker. Typically, they change based on the size of the bet. For our purposes, we’ll keep things simple and just have a single table. The player wins their bet amount multiplied by the following number:

Hand Payout
Royal flush 250
Straight flush 50
Four of a kind 25
Full house 9
Flush 6
Straight 4
Three of a kind 3
Two Pair 2
One pair (Jacks or higher) 1

Any other hands pay 0.

Getting Started

  1. In the terminal window, run
wget https://scienceacademy.github.io/web/poker.zip

to download a zip file of the code.

  1. In the terminal window, run unzip poker.zip to unzip (decompress) the file.
  2. In the terminal window, run cd poker to change directories into your poker directory.

Specification

Hints

Example

Included in the distribution file is a compiled version of the game coded in C. You can run it with:

./vp

Random seed

In order to properly check for the correct output, your submission needs to use a known “random” sequence. Before submitting, make sure to seed your program’s RNG with the following seed: 581321.

You can set the seed with the seed function from random random library.

How to Test Your Code

There’s no check50 for this assignment. Make sure to run and test your program yourself to make sure its output and behavior matches the example program.

How to Submit

submit50 scienceacademy/problems/2024ap/poker