def PlayGame(game_number): player1 = monopoly.Player(1, buying_threshold=500) player2 = monopoly.Player(2, buying_threshold=500) game0 = monopoly.Game([player1, player2], cutoff=1000, ranking_trading=False) return game0.play()['winner']
def start_game(handler): open('log.txt', 'w').close() p1 = handler.get_argument('p1') p2 = handler.get_argument('p2') p1 = mp.Player(p1) p2 = mp.Player(p2) chances, cs = mp.ccs.init(mp.logger, [p1, p2]) p1.chances = chances p2.chances = chances p1.cs = cs p2.cs = cs game.add_players(p1, p2)
def PlaySet(results_q, games_in_a_set=1000): counter = 0 for i in range(games_in_a_set): # Play game. player1 = monopoly.Player(1, buying_threshold=500) player2 = monopoly.Player(2, buying_threshold=500) game0 = monopoly.Game([player1, player2], cutoff=1000, ranking_trading=False) results = game0.play() # Store length. if results['winner'] == 1: counter += 1 results_q.put(counter / games_in_a_set)
def PlaySimpleSet(games_in_a_set=1000): counter = 0 for i in range(games_in_a_set): # Play game. player1 = monopoly.Player(1, buying_threshold=500, group_ordering=random_ordering()) player2 = monopoly.Player(2, buying_threshold=500, group_ordering=random_ordering()) game0 = monopoly.Game([player1, player2], cutoff=1000, new_trading=True) results = game0.play() #print('trade count=', results['trade_count']) #print('game length = ', results['length']) # Store length. if results['winner'] == 1: counter += 1 return counter / games_in_a_set
def main(games_in_a_set=1000): game0 = monopoly.Game(cutoff=1000, trading_enabled=True) for prop1 in game0.board: if prop1.is_property: winners = [0, 0, 0] for i in range(games_in_a_set): # Play game. player1 = monopoly.Player(1, buying_threshold=100, group_ordering=random_ordering(), initial_properties=[prop1]) player2 = monopoly.Player(2, buying_threshold=100, group_ordering=random_ordering()) game0.new_players([player1, player2]) results = game0.play() # Store length. winners[results['winner']] += 1 print(winners, prop1.name)
# -*- coding: utf-8 -*- """ AUTHOR: Joshua W. Johnstone NAME: example.py PURPOSE: Test / show an example of Monopoly simulator """ import monopoly #%% Define players player1 = monopoly.Player(name='Josh', cash_threshold=50) player2 = monopoly.Player(name='Austin') player3 = monopoly.Player(name='Zander') player4 = monopoly.Player(name='Scott', cash_threshold=500) #%% Configure game game = monopoly.Game(players=[player1, player2, player3, player4], debug=True) for player in game.players: print(player.name) #%% Play one round game.reset() game.play_round() #%% Play a whole game game.debug = True game.play() #%% Print the board