Skip to content

Instantly share code, notes, and snippets.

@edenau
Created January 5, 2020 01:30
Show Gist options
  • Save edenau/b23e2b336053fb48edc3c316f6539ab8 to your computer and use it in GitHub Desktop.
Save edenau/b23e2b336053fb48edc3c316f6539ab8 to your computer and use it in GitHub Desktop.
Chance of ending up in Jail after your first turn of Monopoly
# probability of getting imprisoned (not just visiting) in your first turn of a game
n_game = 1e6
n_round = 1
player = Player()
imprisoned_cnt = 0
board = Board()
for i in range(n_game): # simulate 10,000 games
player.new_game()
board.turn(player=player) # simulate a turn for each player
if player.imprisoned:
imprisoned_cnt += 1
print(f'There is a {imprisoned_cnt/n_game*100:.2f}% chance that you are in Jail after one turn.')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment