A row of slot machines, each paying 1 (a win) or 0 per play. You know each machine’s average_wins so far, how many plays it has had, and total_plays across all of them. Write pick_machine(average_wins, plays, total_plays): which machine to play next, as its position (0 for the first), so that over many plays you win as much as you can.
Machine A has paid 0.6 a play over 100 plays; machine B 0.5 over just 2. Play them yourself: is B really worse, or just barely tried?
pick_machine(average_wins, plays, total_plays)| average_wins | each machine's average payout so far (0 if never played) | e.g. [0.4, 0, 0.7] |
| plays | how many times each machine has been played | e.g. [10, 0, 20] |
| total_plays | all plays so far | e.g. 30 |
| returns | the position of the machine to play next (0 = the first) | |