Exemplo n.º 1
0
    def _correct_action(self, data):
        try:
            data["amount"] = int(data["amount"])
        except:
            data["amount"] = -1
        players = global_game_manager.engine.current_state[
            "table"].seats.players
        next_player_pos = global_game_manager.engine.current_state[
            "next_player"]
        sb_amount = global_game_manager.engine.current_state[
            "small_blind_amount"]
        actions = AU.generate_legal_actions(players, next_player_pos,
                                            sb_amount)

        if data["action"] == "fold":
            data["amount"] = 0
        elif data["action"] == "call":
            data["amount"] = actions[1]["amount"]
        else:
            legal = actions[2]["amount"]
            if legal["min"] <= data["amount"] <= legal["max"]:
                data["amount"] = data["amount"]
            else:
                data["action"] = "fold"
                data["amount"] = 0
        return data["action"], data["amount"]
Exemplo n.º 2
0
 def test_generate_legal_actions(self):
     players = _setup_blind_players()
     legal_actions = U.generate_legal_actions(players, 0, "dummy_sb_amount")
     self.eq(
             [
                 { "action": "fold", "amount": 0 },
                 { "action": "call", "amount": 10 },
                 { "action": "raise", "amount": { "min": 15, "max": 100 } }
             ], legal_actions)
Exemplo n.º 3
0
 def test_generate_legal_actions(self):
     players = _setup_blind_players()
     legal_actions = U.generate_legal_actions(players, 0, "dummy_sb_amount")
     self.eq([{
         "action": "fold",
         "amount": 0
     }, {
         "action": "call",
         "amount": 10
     }, {
         "action": "raise",
         "amount": {
             "min": 15,
             "max": 100
         }
     }], legal_actions)
Exemplo n.º 4
0
 def test_generate_legal_actions(self):
     players = _setup_blind_players()
     legal_actions = U.generate_legal_actions(players, 0, 'dummy_sb_amount')
     self.eq([{
         'action': 'fold',
         'amount': 0
     }, {
         'action': 'call',
         'amount': 10,
         'paid': 5
     }, {
         'action': 'raise',
         'amount': {
             'min': 15,
             'max': 100
         },
         'paid': 5
     }], legal_actions)
Exemplo n.º 5
0
    def _correct_action(self, data):
        try:
            data["amount"] = int(data["amount"])
        except:
            data["amount"] = -1
        players = global_game_manager.engine.current_state["table"].seats.players
        next_player_pos = global_game_manager.engine.current_state["next_player"]
        sb_amount = global_game_manager.engine.current_state["small_blind_amount"]
        actions = AU.generate_legal_actions(players, next_player_pos, sb_amount)

        if data["action"] == "fold":
            data["amount"] = 0
        elif data["action"] == "call":
            data["amount"] = actions[1]["amount"]
        else:
            legal = actions[2]["amount"]
            if legal["min"] <= data["amount"] <= legal["max"]:
                data["amount"] = data["amount"]
            else:
                data["action"] = "fold"
                data["amount"] = 0
        return data["action"], data["amount"]