Several years ago, when I was a university professor, one of the homework problems I assigned to students in the beginning programming class was to simulate the game of chuck-a-luck.
Chuck-a-luck has three dice. You place a bet on one of the six dice numbers (1, 2, 3, 4, 5, 6) then roll the three dice. If your selected number appears on all three dice you win $3. If your number appears on two of the three dice you win $2. If your number appears on one of the dice you win $1. If your number doesn’t appear on any of the three dice you lose $1.

Left: The Wikipedia article on chuck-a-luck shows the exact calculation of the house advantage for chuck-a-luck. Right: The game often uses a birdcage-like device to roll the three dice.
Even for such a simple problem there are many different design possibilities.
Chuck-a-luck is no longer played in casinos because the house advantage is very large — about 7.87%, meaning for each dollar bet, you’d lose almost 8 cents on average.

Dice in fashion. The red dress is very nice, but the earrings, shoes, and glasses are somewhat dicey I think.
Demo code:
# chuck_a_luck.py
import numpy as np
np.random.seed(3)
b = 5 # number bet on
bank_start = 0
bank = bank_start
bet = 1 # bet amount
plays = 1_000_000
print("\nPlaying chuck-a-luck %d times " % plays)
for i in range(plays):
matches = 0
d1 = np.random.randint(1,7) # from 1 to 6
d2 = np.random.randint(1,7)
d3 = np.random.randint(1,7)
# print(d1)
# print(d2)
# print(d3)
if d1 == b: matches += 1
if d2 == b: matches += 1
if d3 == b: matches += 1
if matches == 0: bank -= 1 * bet
elif matches == 1: bank += 1 * bet
elif matches == 2: bank += 2 * bet
elif matches == 3: bank += 3 * bet
print("Done \n")
print("final bank = %d " % bank)
net_gain = bank - bank_start
print("net gain = %d " % net_gain)
avg_gain = net_gain / bet # avg gain per dollar bet
avg_gain = avg_gain / plays
print("average gain per dollar played = %0.4f " % avg_gain)

.NET Test Automation Recipes
Software Testing
SciPy Programming Succinctly
Keras Succinctly
R Programming
2026 Visual Studio Live
2025 Summer MLADS Conference
2025 DevIntersection Conference
2025 Machine Learning Week
2025 Ai4 Conference
2025 G2E Conference
2025 iSC West Conference
You must be logged in to post a comment.