Multi-armed bandit simulator

A casino has four slot machines, each with an unknown payoff distribution. You have a limited number of pulls. Which machine do you play, and when do you stop exploring? Tune the machines and the strategy parameters below, then watch four classic algorithms compete on reward and regret.

Strategy parameters
Slot machines (payoff per pull)
Best machine
Oracle max payoff
Total pulls
Cumulative regret — lower is better (distance from the oracle)
Cumulative reward — higher is better
Machine payoff distributions — overlap is what makes the problem hard
Arm selection — how many times each strategy pulled each machine
Run log — the machine each strategy picked over time (left to right)

How it works

Pure greedy tries each machine once, then always plays the current best average — cheap, but easily fooled by early luck. ε-greedy plays greedy but explores a random machine with probability ε. UCB picks by an optimistic upper confidence bound, exploring machines it is unsure about. Thompson sampling draws a plausible value for each machine from its posterior and plays the winner. Regret is the cumulative payoff lost versus always playing the true best machine — the headline "cost of indecision" number.