Skip to contents

Simulate “Full Pay Jacks or Better” optimal strategy video poker. As the linked article notes:

The following strategy is for full pay Jacks or Better video poker. “Full Pay” designates the following paytable, per coin based on five coins bet, which returns 99.54% of money bet assuming optimal strategy.

library(cards)
library(tibble)
library(dplyr)

deck <- new_deck()
runs <- 2e6

One Hand

Run simple simulations with a single hand, without drawing new cards.

hands <- replicate(runs, eval_hand(deal_hand(deck)))

Calculate payouts, using the table from the optimal strategy article and these pay tables:

Hand Payout
Royal Flush 800
Straight Flush 50
Four of a Kind 25
Full House 9
Flush 6
Straight 4
Three of a Kind 3
Two Pair 2
Jacks or Better 1

Payout is per coin when betting 5 coins.

payout <- hands |>
  as_tibble_col(column_name = "hand") |>
  mutate(payout = case_match(
    hand,
    c("high_card", "one_pair") ~ 0,
    "jacks_better" ~ 1,
    "two_pair" ~ 2,
    "three_ofakind" ~ 3,
    "straight" ~ 4,
    "flush" ~ 6,
    "full_house" ~ 9,
    "four_ofakind" ~ 25,
    "straight_flush" ~ 50,
    "royal_flush" ~ 800
  ))

Filter only Royal Flushes:

payout |>
  filter(payout == 800)
#> # A tibble: 3 × 2
#>   hand        payout
#>   <chr>        <dbl>
#> 1 royal_flush    800
#> 2 royal_flush    800
#> 3 royal_flush    800

Calculate the total payout, and percentage return:

total <- payout |>
  pull(payout) |>
  sum()

total
#> [1] 675314
total / runs
#> [1] 0.337657

A simple “one hand” simulation performs much poorer than the expected return of 99.54% for optimal strategy.