This is a simulation of the Martindale strategy for the game of roulette. This simulation allows for one, two and three zero wheels.

martingale_simulation <- function(max_spins, n_zeros=1){
  # Initial conditions
  dollars <- 100
  bet <- 1
  i <- 1
  # Get the roulette wheel
  if (n_zeros == 3){
    # Three zero wheel
    wheel <- c("Green", "Green", "Green", "Red", "Black", "Red", "Black", "Red", "Black", "Red", "Black", "Red", "Black", "Red", "Black", "Red", "Black", "Red", "Black", "Red", "Black", "Red", "Black", "Red", "Black", "Red", "Black", "Red", "Black", "Red", "Black", "Red", "Black", "Red", "Black", "Red", "Black", "Red", "Black")
  } else if (n_zeros == 2){
    # Two zero wheel
    wheel <- c("Green", "Black", "Red", "Black", "Red", "Black", "Red", "Black", "Red", "Black", "Red", "Black", "Red", "Black", "Red", "Black", "Red", "Black", "Red", "Green", "Red", "Black", "Red", "Black", "Red", "Black", "Red", "Black", "Red", "Black", "Red", "Black", "Red", "Black", "Red", "Black", "Red", "Black")
  }else {
    # One zero wheel
    wheel <- c("Green", "Red", "Black", "Red", "Black", "Red", "Black", "Red", "Black", "Red", "Black", "Red", "Black", "Red", "Black", "Red", "Black", "Red", "Black", "Red", "Black", "Red", "Black", "Red", "Black", "Red", "Black", "Red", "Black", "Red", "Black", "Red", "Black", "Red", "Black", "Red", "Black")
  }
  # Check for quit conditions
  while (dollars < 105 && dollars > 0 && i < max_spins){
    # Spin the wheel
    color <- sample(wheel, 1)
    if (color == "Red"){
      # Winner!
      dollars <- dollars + bet
      bet <- 1
    } else {
      # Looser!
      dollars <- dollars - bet
      bet <- bet * 2
    }
    i <- i + 1
  }
  # Send back the amount winnings/losses
  return(dollars)
}

Run the Simulations

Now that the simulation function has been defines let’s run the simulation. In order to ensure a reliable sense of the success rate of this strategy I will run multiple “deep” (1,000) simulations.

# Make this repeatable
set.seed(12345)

# Depth and breadth of the simulation
n <- 1000

# Run simulation for each roulette wheel type
for (n_zeros in 1:3) {
  # This will hold the simulation data
  results <- c()
  successful <- c()
  # Simulate
  for (j in 1:n) {
    for (i in 1:n) {
      # Most observed simulations gets to the quit state within 20 spins,
      # but we will use 50 to allow for any edge case
      results[i] <- martingale_simulation(50, n_zeros)
    }
    # Summarize the simulation
    results_table <- table(results)
    # Express the successful runs as a percentage of all runs
    successful[j] <- results_table[names(results_table) == "105"] / n
  }
  # Aggregate the simulation results in a data frame
  row <- data.frame(success_rate = successful, zeros = c(n_zeros))
  if (exists("simulation_results")){
    simulation_results <- rbind(simulation_results, row)
  } else {
    simulation_results <- row
  }
}

Summary

zeros minimum median mean maximum
1 0.933 0.954 0.954187 0.971
2 0.922 0.946 0.945113 0.969
3 0.911 0.937 0.936617 0.958