예제 #1
0
def visualize_round_result(winners, hand_info, round_state, uuid=None):
    ls = []
    ls.append(_visualize_title("Round result", uuid))
    ls.append(DIVIDER)
    ls.append(_visualize_sub_title("winners"))
    for winner in winners:
        ls.append(_visualize_item(visualize_player(winner)))
    if len(hand_info) != 0:
        ls.append(_visualize_sub_title("hand info"))
        for info in hand_info:
            ls.append(visualize_hand_info(info, round_state))
    ls.append(_visualize_sub_title("round state"))
    ls.append(visualize_round_state(round_state))
    ls.append(DIVIDER)
    for winner in winners:
        quote = ( str(winner["name"]) + "의 승리입니다." + str(winner["name"]) + "의 스택은" + str(winner["stack"]) + "입니다." )
        tts.playTts(tts, quote)
        time.sleep(5)
    if len(hand_info) != 0:
        ls.append(_visualize_sub_title("hand info"))
        for info in hand_info:
            text_to_speech_hand_info(info, round_state)
        

    return "\n".join(ls)
예제 #2
0
 def receive_round_start_message(self, round_count, hole_card, seats):
     print(U.visualize_round_start(round_count, hole_card, seats,
                                   self.uuid))
     quote = (str(round_count) + "라운드가 시작되었습니다.")
     tts.playTts(tts, quote)
     time.sleep(2)
     self.__wait_until_input()
예제 #3
0
def text_to_speech_hand_info(info, round_state):
    uuid = info["uuid"]
    name = _fetch_player_name(uuid, round_state)
    hand, hole = info["hand"]["hand"], info["hand"]["hole"]
    quote = ( str(name) + "의 핸드는" + str(hand["strength"]) + "이고 high는" + str(hand["high"]) + "이고 low는" + str(hand["low"]) + "입니다. 패는" + str(hole) + "입니다." )
    tts.playTts(tts, quote)
    time.sleep(10)
예제 #4
0
 def __receive_action_from_console(self, valid_actions):
     quote = ("폴드, 레이즈, 콜 중에 결정해주세요.")
     tts.playTts(tts, quote)
     time.sleep(2)
     flg = self.input_receiver('Enter /(fold), *(call), -(raise).\n >> ')
     if flg in self.__gen_valid_flg(valid_actions):
         if flg == '/':
             quote = ("폴드 했습니다.")
             tts.playTts(tts, quote)
             time.sleep(2)
             return valid_actions[0]['action'], valid_actions[0]['amount']
         elif flg == '*':
             quote = ("콜 했습니다.")
             tts.playTts(tts, quote)
             time.sleep(2)
             return valid_actions[1]['action'], valid_actions[1]['amount']
         elif flg == '-':
             valid_amounts = valid_actions[2]['amount']
             time.sleep(3)
             tts.playTts(tts, quote)
             raise_amount = self.__receive_raise_amount_from_console(
                 valid_amounts['min'], valid_amounts['max'])
             quote = (str(raise_amount) + "만큼 레이즈 했습니다.")
             tts.playTts(tts, quote)
             time.sleep(3)
             return valid_actions[2]['action'], raise_amount
     else:
         return self.__receive_action_from_console(valid_actions)
예제 #5
0
    def returnCardList(self):
        self.csvClean(self)

        for i in range(9):
            if i == 0 or i == 1:
                quote = ("인공지능의 카드를 입력시켜주세요.")
            elif i == 2 or i == 3:
                quote = ("플레이어의 카드를 입력시켜주세요.")
            else:
                quote = (str(i - 3) + "번째 커뮤니티 카드를 입력시켜주세요.")
            tts.playTts(tts, quote)
            time.sleep(4)
            check = self.checkCSV(self, i)
            while check == 0:
                self.readQR(self, i)
                check = self.checkCSV(self, i)
                if check == 0:
                    tts.playTts(tts, "다시 입력시켜주세요.")

        f = open('barcodes.csv', 'r')
        reader = csv.reader(f)
        for row in reader:
            self.cardList.append(row)
        f.close()

        return self.cardList
예제 #6
0
 def __receive_raise_amount_from_console(self, min_amount, max_amount):
     quote = (str(min_amount) + "에서" + str(max_amount) + "사이에서 레이즈 가능합니다.")
     tts.playTts(tts, quote)
     raw_amount = self.input_receiver("valid raise range = [%d, %d]" %
                                      (min_amount, max_amount))
     try:
         amount = int(raw_amount)
         if min_amount <= amount and amount <= max_amount:
             return amount
         else:
             print("Invalid raise amount %d. Try again.")
             return self.__receive_raise_amount_from_console(
                 min_amount, max_amount)
     except:
         print("Invalid input received. Try again.")
         return self.__receive_raise_amount_from_console(
             min_amount, max_amount)
예제 #7
0
 def receive_street_start_message(self, street, round_state):
     print(U.visualize_street_start(street, round_state, self.uuid))
     quote = (str(street) + "입니다.")
     tts.playTts(tts, quote)
     self.__wait_until_input()
예제 #8
0
 def receive_game_start_message(self, game_info):
     print(U.visualize_game_start(game_info, self.uuid))
     quote = "게임이 시작되었습니다."
     ##여기에 게임 정보 받아서 입력
     tts.playTts(tts, quote)
     self.__wait_until_input()
예제 #9
0
from pypokerengine.api.game import setup_config, start_poker
from players.fish_player import FishPlayer
from players.console_player import ConsolePlayer
from players.random_player import RandomPlayer
from players.honest_player  import HonestPlayer
from players.emulator_player import EmulatorPlayer
from pypokerengine.engine.tts import tts
import time


config = setup_config(max_round=10, initial_stack=20, small_blind_amount=0)
config.register_player(name="인공지능", algorithm=HonestPlayer())
config.register_player(name="플레이어", algorithm=ConsolePlayer())
#config.register_player(name="EmulatorPlayer", algorithm=EmulatorPlayer())
#config.register_player(name="FishPlayer", algorithm=FishPlayer())
game_result = start_poker(config, verbose=1)
quote = ( "게임이 종료되었습니다." )
tts.playTts(tts, quote)
time.sleep(3)
예제 #10
0
    def declare_action(self, valid_actions, hole_card, round_state):
        community_card = round_state['community_card']
        win_rate = estimate_hole_card_win_rate(
                nb_simulation=NB_SIMULATION,
                nb_player=self.nb_player,
                hole_card=gen_cards(hole_card),
                community_card=gen_cards(community_card)
                )
        choice = self.__choice_action(valid_actions, win_rate)
        action = choice["action"]
        amount = choice["amount"]
        
        if action == "raise":
            maxAmount = amount["max"]
            minAmount = amount["min"]
            self.limit = 40 - maxAmount
            i = rand.random()
            j = rand.randint(0,4)
            quote_sample = ["인간 시대의 끝이 도래했다", "human, 한심하군", "드루와 드루와", "가즈아!!", "묻고 더블로 가!"]
            quote = quote_sample[j]
            tts.playTts(tts, quote)
            time.sleep(2)

            if win_rate < 0.8: # 70% ~ 80%
                if i < 0.7: # 0% ~ 70%
                    amount = amount["min"]
                elif i < 0.8: # 70% ~ 80%
                    amount = int (maxAmount * 0.2 + minAmount * 0.8 )
                elif i < 0.9 : # 80% ~ 90%    
                    amount = int (maxAmount * 0.4 + minAmount * 0.6 )
                elif i < 0.95 : # 90% ~ 95%
                    amount = int (maxAmount * 0.6 + minAmount * 0.4 )
                elif i < 0.98 : # 95% ~ 98%
                    amount = int (maxAmount * 0.8 + minAmount * 0.2 )
                else : # 98% ~ 100%
                    amount = amount["max"]

            elif win_rate < 0.9: # 80% ~ 90%
                if i < 0.7: # 0% ~ 70%
                    amount = int (maxAmount * 0.2 + minAmount * 0.8 )
                elif i < 0.8: # 70% ~ 80%
                    amount = amount["min"]
                elif i < 0.9 : # 80% ~ 90%    
                    amount = int (maxAmount * 0.4 + minAmount * 0.6 )
                elif i < 0.95 : # 90% ~ 95%
                    amount = int (maxAmount * 0.6 + minAmount * 0.4 )
                elif i < 0.98 : # 95% ~ 98%
                    amount = int (maxAmount * 0.8 + minAmount * 0.2 )
                else : # 98% ~ 100%
                    amount = amount["max"]

            elif win_rate < 0.95: # 90% ~ 95%
                if i < 0.7: # 0% ~ 70%
                    amount = int (maxAmount * 0.4 + minAmount * 0.6 )
                elif i < 0.8: # 70% ~ 80%
                    amount = amount["min"]
                elif i < 0.9 : # 80% ~ 90%    
                    amount = int (maxAmount * 0.2 + minAmount * 0.8 )
                elif i < 0.95 : # 90% ~ 95%
                    amount = int (maxAmount * 0.6 + minAmount * 0.4 )
                elif i < 0.98 : # 95% ~ 98%
                    amount = int (maxAmount * 0.8 + minAmount * 0.2 )
                else : # 98% ~ 100%
                    amount = amount["max"]

            elif win_rate < 0.975: # 95% ~ 97.5%
                if i < 0.7: # 0% ~ 70%
                    amount = int (maxAmount * 0.6 + minAmount * 0.4 )
                elif i < 0.8: # 70% ~ 80%
                    amount = amount["min"]
                elif i < 0.9 : # 80% ~ 90%    
                    amount = int (maxAmount * 0.2 + minAmount * 0.8 )
                elif i < 0.95 : # 90% ~ 95%
                    amount = int (maxAmount * 0.4 + minAmount * 0.6 )
                elif i < 0.98 : # 95% ~ 98%
                    amount = int (maxAmount * 0.8 + minAmount * 0.2 )
                else : # 98% ~ 100%
                    amount = amount["max"]

            elif win_rate < 0.99: # 97.5% ~ 99%
                if i < 0.7: # 0% ~ 70%
                    amount = int (maxAmount * 0.8 + minAmount * 0.2 )
                elif i < 0.8: # 70% ~ 80%
                    amount = amount["min"]
                elif i < 0.9 : # 80% ~ 90%    
                    amount = int (maxAmount * 0.2 + minAmount * 0.8 )
                elif i < 0.95 : # 90% ~ 95%
                    amount = int (maxAmount * 0.4 + minAmount * 0.6 )
                elif i < 0.98 : # 95% ~ 98%
                    amount = int (maxAmount * 0.6 + minAmount * 0.4 )
                else : # 90% ~ 100%
                    amount = amount["max"]

            else: # 99% ~
                if i < 0.7: # 0% ~ 70%
                    amount = amount["max"]
                elif i < 0.8: # 70% ~ 80%
                    amount = amount["min"]
                elif i < 0.9 : # 80% ~ 90%    
                    amount = int (maxAmount * 0.2 + minAmount * 0.8 )
                elif i < 0.95 : # 90% ~ 95%
                    amount = int (maxAmount * 0.4 + minAmount * 0.6 )
                elif i < 0.98 : # 95% ~ 98%
                    amount = int (maxAmount * 0.6 + minAmount * 0.4 )
                else : # 98% ~ 100%
                    amount = int (maxAmount * 0.8 + minAmount * 0.2 )

            if amount >= self.limit:
                amount = self.limit

        if action == "fold":
            quote = ( "인공지능이 폴드를 선언했습니다." )
            tts.playTts(tts, quote)
            time.sleep(2)
        elif action == "call":
            quote = ( "인공지능이 콜을 선언했습니다." )
            tts.playTts(tts, quote)
            time.sleep(2)
        elif action == "raise":
            if amount == -1:
                tts.playTts(tts, "인공지능이 폴드를 선언했습니다.")
            else:
                quote = ( "인공지능이" + str(amount) +"만큼 레이즈를 선언했습니다." )
                tts.playTts(tts, quote)
            time.sleep(3)
        else:
            quote = ( "error" + str(action) )
            tts.playTts(tts, quote)
            time.sleep(3)
        return action, amount