Skip to content

Instantly share code, notes, and snippets.

@Jsevillamol
Created April 11, 2018 17:03
Show Gist options
  • Save Jsevillamol/bf2b42d60143c2a09ee871e1acd27a98 to your computer and use it in GitHub Desktop.
Save Jsevillamol/bf2b42d60143c2a09ee871e1acd27a98 to your computer and use it in GitHub Desktop.
Public bet between Kyle and Jaime
# -*- coding: utf-8 -*-
"""
Created on Mon Apr 9 15:48:18 2018
@author: jsevillamol
"""
# After the game, I get either $1000 or the value of C in dollars rounded to nearest cent
# You can ask the 3rd party to run the flip_n_times() function as many times as you want within the 2h
# If C overflows during the game, the game ends and I get $1000 dollars
import random
alpha = 0.7 # fraction of net worth bid every time for heads
prob = 0.7 # probability of heads
payoff = 2 # multiplying factor on right bet
n = 1000 # number of flips
C = 50 # starting net worth
def flip(C):
result = random.random()
if result < prob: return C*alpha*payoff
else: return C*(1-alpha)*payoff
def flip_n_times():
global C
for i in range(n):
C = flip(C)
return C
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment