def __accept_action(self, state, action, bet_amount, bot_info=None): player = state["table"].seats.players[state["next_player"]] if action == 'call': self.__chip_transaction(player, bet_amount) player.add_action_history(Const.Action.CALL, bet_amount, bot_info=bot_info) elif action == 'raise': self.__chip_transaction(player, bet_amount) add_amount = bet_amount - ActionChecker.agree_amount(state["table"].seats.players) player.add_action_history(Const.Action.RAISE, bet_amount, add_amount, bot_info=bot_info) elif action == 'fold': player.add_action_history(Const.Action.FOLD, bot_info=bot_info) player.pay_info.update_to_fold() else: raise ValueError("Unexpected action %s received" % action) return state
def __update_state_by_action(self, state, action): table = state["table"] current_amount = ActionChecker.agree_amount( state["table"].seats.players) bet = ActionChecker.round_raise_amount(state["small_blind_amount"], state["street"]) if action == "raise": amount = current_amount + bet[0] elif action == "call": amount = current_amount elif action == "fold": amount = 0 else: amount = 0 action, bet_amount = ActionChecker.correct_action(\ table.seats.players, state["next_player"], state["small_blind_amount"], action, amount) next_player = table.seats.players[state["next_player"]] if ActionChecker.is_allin(next_player, action, bet_amount): next_player.pay_info.update_to_allin() return self.__accept_action(state, action, bet_amount), amount
def __accept_action(self, state, action, bet_amount): player = state["table"].seats.players[state["next_player"]] if action == 'call': self.__chip_transaction(player, bet_amount) player.add_action_history(Const.Action.CALL, bet_amount) print("@@@@@player : ", player.name, "@@@@@\n") print("@@@@@bet_amount : ", bet_amount, "@@@@@\n") led.led(led, player.name, bet_amount) elif action == 'raise': self.__chip_transaction(player, bet_amount) add_amount = bet_amount - ActionChecker.agree_amount(state["table"].seats.players) player.add_action_history(Const.Action.RAISE, bet_amount, add_amount) print("@@@@@player : ", player.name, "@@@@@\n") print("@@@@@bet_amount : ", bet_amount, "@@@@@\n") #bet_amount 만큼 칩을 뱉어야 함 print("@@@@@add_amount : ", add_amount, "@@@@@\n") led.led(led, player.name, bet_amount) elif action == 'fold': player.add_action_history(Const.Action.FOLD) player.pay_info.update_to_fold() else: raise ValueError("Unexpected action %s received" % action) return state