Created
January 5, 2020 01:30
-
-
Save edenau/b23e2b336053fb48edc3c316f6539ab8 to your computer and use it in GitHub Desktop.
Chance of ending up in Jail after your first turn of Monopoly
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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