Пример #1
0
    def test_exclude_short_of_money_player_when_ante_on(self):
        dealer = Dealer(5, 100, 20)
        blind_structure = {3: {'ante': 30, 'small_blind': 10}}
        dealer.set_blind_structure(blind_structure)
        algos = [FoldMan() for _ in range(5)]
        [
            dealer.register_player('algo-%d' % idx, algo)
            for idx, algo in enumerate(algos)
        ]
        dealer.table.dealer_btn = 3
        # initialize stack
        for idx, stack in enumerate([1000, 30, 46, 1000, 85]):
            dealer.table.seats.players[idx].stack = stack

        def fetch_stacks(res):
            return [
                p['stack'] for p in res['message']['game_information']['seats']
            ]

        result = dealer.start_game(1)
        self.eq(fetch_stacks(result), [1085, 10, 26, 980, 60])
        result = dealer.start_game(2)
        self.eq(fetch_stacks(result), [1060, 0, 0, 1025, 40])
        result = dealer.start_game(3)
        self.eq(fetch_stacks(result), [1100, 0, 0, 985, 0])
        result = dealer.start_game(4)
        self.eq(fetch_stacks(result), [1060, 0, 0, 1025, 0])
Пример #2
0
    def test_set_blind_structure(self):
        dealer = Dealer(5, 100, 3)
        dealer.table.dealer_btn = 2
        blind_structure = {
            3: {
                'ante': 7,
                'small_blind': 11
            },
            4: {
                'ante': 13,
                'small_blind': 30
            }
        }
        dealer.set_blind_structure(blind_structure)
        algos = [FoldMan() for _ in range(3)]
        [
            dealer.register_player('algo-%d' % idx, algo)
            for idx, algo in enumerate(algos)
        ]

        def fetch_stacks(res):
            return [
                p['stack'] for p in res['message']['game_information']['seats']
            ]

        result = dealer.start_game(1)
        self.eq(fetch_stacks(result), [92, 111, 97])
        result = dealer.start_game(2)
        self.eq(fetch_stacks(result), [89, 103, 108])
        result = dealer.start_game(3)
        self.eq(fetch_stacks(result), [114, 96, 90])
        result = dealer.start_game(4)
        self.eq(fetch_stacks(result), [71, 152, 77])
        result = dealer.start_game(5)
        self.eq(fetch_stacks(result), [58, 109, 133])
Пример #3
0
    def test_exclude_short_of_money_player_when_ante_on(self):
        dealer = Dealer(5, 100, 20)
        blind_structure = {3: {"ante": 30, "small_blind": 10}}
        dealer.set_blind_structure(blind_structure)
        algos = [FoldMan() for _ in range(5)]
        [
            dealer.register_player("algo-%d" % idx, algo)
            for idx, algo in enumerate(algos)
        ]
        dealer.table.dealer_btn = 3
        # initialize stack
        for idx, stack in enumerate([1000, 30, 46, 1000, 85]):
            dealer.table.seats.players[idx].stack = stack
        fetch_stacks = lambda res: [
            p["stack"] for p in res["message"]["game_information"]["seats"]
        ]

        result = dealer.start_game(1)
        self.eq(fetch_stacks(result), [1085, 10, 26, 980, 60])
        result = dealer.start_game(2)
        self.eq(fetch_stacks(result), [1060, 0, 0, 1025, 40])
        result = dealer.start_game(3)
        self.eq(fetch_stacks(result), [1100, 0, 0, 985, 0])
        result = dealer.start_game(4)
        self.eq(fetch_stacks(result), [1060, 0, 0, 1025, 0])
Пример #4
0
 def test_set_blind_structure(self):
     dealer = Dealer(5, 100, 3)
     dealer.table.dealer_btn = 2
     blind_structure = {
         3: {
             "ante": 7,
             "small_blind": 11
         },
         4: {
             "ante": 13,
             "small_blind": 30
         }
     }
     dealer.set_blind_structure(blind_structure)
     algos = [FoldMan() for _ in range(3)]
     [
         dealer.register_player("algo-%d" % idx, algo)
         for idx, algo in enumerate(algos)
     ]
     fetch_stacks = lambda res: [
         p["stack"] for p in res["message"]["game_information"]["seats"]
     ]
     result = dealer.start_game(1)
     self.eq(fetch_stacks(result), [92, 111, 97])
     result = dealer.start_game(2)
     self.eq(fetch_stacks(result), [89, 103, 108])
     result = dealer.start_game(3)
     self.eq(fetch_stacks(result), [114, 96, 90])
     result = dealer.start_game(4)
     self.eq(fetch_stacks(result), [71, 152, 77])
     result = dealer.start_game(5)
     self.eq(fetch_stacks(result), [58, 109, 133])
Пример #5
0
def start_poker(config, verbose=2):
    config.validation()
    dealer = Dealer(config.sb_amount, config.initial_stack, config.ante)
    dealer.set_verbose(verbose)
    dealer.set_blind_structure(config.blind_structure)
    for info in config.players_info:
        dealer.register_player(info["name"], info["algorithm"])
    result_message = dealer.start_game(config.max_round)
    return _format_result(result_message)
Пример #6
0
def start_poker(config, verbose=2):
    config.validation()
    dealer = Dealer(config.sb_amount, config.initial_stack, config.ante)
    dealer.set_verbose(verbose)
    dealer.set_blind_structure(config.blind_structure)
    for info in config.players_info:
        dealer.register_player(info["name"], info["algorithm"])
    result_message = dealer.start_game(config.max_round)
    return _format_result(result_message)
Пример #7
0
def start_poker(config, verbose=2, full_summary=False):
    config.validation()
    dealer = Dealer(config.sb_amount, config.initial_stack, config.ante,
                    config.summary_file)
    dealer.set_verbose(verbose)
    dealer.set_blind_structure(config.blind_structure)
    for info in config.players_info:
        dealer.register_player(info["name"], info["algorithm"])
    result_message = dealer.start_game(config.max_round)
    if full_summary:
        return dealer.game_summarizer.get_summary()
    else:
        return _format_result(result_message)
Пример #8
0
def start_poker(config,
                verbose=2,
                cashgame: bool = False,
                log_file_location: str = ''):
    config.validation()
    dealer = Dealer(config.sb_amount, config.initial_stack, config.ante,
                    log_file_location)
    dealer.set_verbose(verbose)
    dealer.set_blind_structure(config.blind_structure)
    for info in config.players_info:
        dealer.register_player(info["name"], info["algorithm"])
    result_message = dealer.start_game(config.max_round, cashgame=cashgame)
    return _format_result(result_message)
Пример #9
0
 def test_set_blind_structure(self):
   dealer = Dealer(5, 100, 3)
   dealer.table.dealer_btn = 2
   blind_structure = { 3:{"ante":7, "small_blind": 11}, 4:{"ante":13, "small_blind":30} }
   dealer.set_blind_structure(blind_structure)
   algos = [FoldMan() for _ in range(3)]
   [dealer.register_player("algo-%d" % idx, algo) for idx, algo in enumerate(algos)]
   fetch_stacks = lambda res: [p["stack"] for p in res["message"]["game_information"]["seats"]]
   result = dealer.start_game(1)
   self.eq(fetch_stacks(result), [92, 111, 97])
   result = dealer.start_game(2)
   self.eq(fetch_stacks(result), [89, 103, 108])
   result = dealer.start_game(3)
   self.eq(fetch_stacks(result), [114, 96, 90])
   result = dealer.start_game(4)
   self.eq(fetch_stacks(result), [71, 152, 77])
   result = dealer.start_game(5)
   self.eq(fetch_stacks(result), [58, 109, 133])
Пример #10
0
  def test_exclude_short_of_money_player_when_ante_on(self):
    dealer = Dealer(5, 100, 20)
    blind_structure = { 3:{"ante":30, "small_blind": 10}}
    dealer.set_blind_structure(blind_structure)
    algos = [FoldMan() for _ in range(5)]
    [dealer.register_player("algo-%d" % idx, algo) for idx, algo in enumerate(algos)]
    dealer.table.dealer_btn = 3
    # initialize stack
    for idx, stack in enumerate([1000, 30, 46, 1000, 85]):
      dealer.table.seats.players[idx].stack = stack
    fetch_stacks = lambda res: [p["stack"] for p in res["message"]["game_information"]["seats"]]

    result = dealer.start_game(1)
    self.eq(fetch_stacks(result), [1085, 10, 26, 980, 60])
    result = dealer.start_game(2)
    self.eq(fetch_stacks(result), [1060, 0, 0, 1025, 40])
    result = dealer.start_game(3)
    self.eq(fetch_stacks(result), [1100, 0, 0, 985, 0])
    result = dealer.start_game(4)
    self.eq(fetch_stacks(result), [1060, 0, 0, 1025, 0])