Skip to content

Instantly share code, notes, and snippets.

@edenau
Created January 5, 2020 01:23
Show Gist options
  • Save edenau/1c676713d68c51eb53991814e395528c to your computer and use it in GitHub Desktop.
Save edenau/1c676713d68c51eb53991814e395528c to your computer and use it in GitHub Desktop.
Main script of Monte Carlo simulation of Monopoly
opponents = []
n_oppo = 4-1 # a 4-player game has 3 opponents
n_game = 1e6
n_round_mean, n_round_std = get_n_round_stat(n_oppo)
# 1. Create opponents in a list
for _ in range(n_oppo):
opponents.append(Player())
# 2. Simulate 1,000,000 games
for i in range(round(n_game)):
# by creating a new board and cleaning each player's states
board = Board()
for player in opponents:
player.new_game()
# 3. Simulate a random number of rounds per game
n_round = np.random.normal(n_round_mean, n_round_std)
for j in range(round(n_round)):
# 4. Simulate each turn for each player
for player in opponents:
board.turn(player=player)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment