Skip to content

Instantly share code, notes, and snippets.

@Svetixbot
Created March 25, 2015 10:12
Show Gist options
  • Save Svetixbot/dfbfb2cc8f13528d2da3 to your computer and use it in GitHub Desktop.
Save Svetixbot/dfbfb2cc8f13528d2da3 to your computer and use it in GitHub Desktop.
import operator
from BanditGame import BanditGame
ba = BanditGame()
results = {}
for arm in range(1, 6):
results[arm] = 0
for game in range(20):
startValue = ba.money()
ba.play(arm)
results[arm] = results[arm] + ba.money()-startValue #how much money you'll gane with this arm
bestArm = max(results.iteritems(), key=operator.itemgetter(1))[0]
while ba._money_check:
ba.play(bestArm)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment