Example #1
0
    def evalStregth(self, isBet=False):
        action = Action.Check
        amount = 0

        pre_percent = self.hands_strength
        if self.stage != Stage.PreFlop and self.stage != Stage.HandOver:
            print("Hand card:")
            Card.print_pretty_cards(self.hands)
            print("Board card:")
            Card.print_pretty_cards(self.board)
            self.hands_strength = self.winRateStrategy.evaluate(
                self.hands, self.board)

        isBetter = (self.hands_strength > pre_percent)

        if self.hands_strength >= 0.9:
            if isBetter:
                action = Action.Allin
            else:
                action = Action.Raise
        elif self.hands_strength >= 0.8 and self.hands_strength < 0.9:
            action = Action.Bet
            amount = max(self.min_bet, self.my_chips / 2)
        elif self.hands_strength >= 0.6 and self.hands_strength < 0.8:
            if self.min_bet < (self.my_chips / 3) and isBetter:
                action = Action.Raise
            elif "allin" in self.opponent_action:
                action = Action.Fold
            else:
                action = Action.Call
        elif self.hands_strength >= 0.5 and self.hands_strength < 0.6:
            if self.min_bet < (self.my_chips /
                               5) and self.my_bet_chips < (self.my_chips / 2):
                action = Action.Call
            else:
                action = Action.Fold
        elif self.hands_strength >= 0.4 and self.hands_strength < 0.5:
            if self.min_bet < (self.my_chips / 10):
                action = Action.Call
            else:
                action = Action.Fold
        elif self.hands_strength >= 0.18 and self.hands_strength < 0.4:
            if not isBet:
                action = Action.Check
            elif self.min_bet < (self.my_chips / 20):
                action = Action.Call
            else:
                action = Action.Fold
        else:
            if self.stage == Stage.PreFlop:
                Card.print_pretty_cards(self.hands)
                if "allin" not in self.opponent_action:
                    action = Action.Call
                else:
                    action = Action.Fold
            else:
                action = Action.Fold

        return (action, amount)
Example #2
0
def GoToShowdown(player_1, player_2):
    if evaluator.evaluate(player_1.board, player_1.hand) == evaluator.evaluate(
            player_2.board, player_2.hand):
        print("Draw")
    elif evaluator.evaluate(player_1.board,
                            player_1.hand) < evaluator.evaluate(
                                player_2.board, player_2.hand):
        print("Player 1 Wins")
    else:
        print("Player 2 Wins")
    print(Card.print_pretty_cards(player_1.board + player_1.hand))
    print("Player 1 hand rank = %d (%s)\n" %
          (evaluator.evaluate(player_1.board, player_1.hand),
           evaluator.class_to_string(
               evaluator.get_rank_class(
                   evaluator.evaluate(player_1.board, player_1.hand)))))
    print(Card.print_pretty_cards(player_2.board + player_2.hand))
    print("Player 2 hand rank = %d (%s)\n" %
          (evaluator.evaluate(player_2.board, player_2.hand),
           evaluator.class_to_string(
               evaluator.get_rank_class(
                   evaluator.evaluate(player_2.board, player_2.hand)))))
Example #3
0
        def PlayerFolded(game, total_games):
            players_hands = []
            for player in table.members:
                players_hands.append(player.cards)

            print("PLAYER_1:\t" + Card.print_pretty_cards(players_hands[0]))
            print("PLAYER_2:\t" + Card.print_pretty_cards(players_hands[1]))
            print("Board:\t" + Card.print_pretty_cards(self.board))
            if player_folded[1] == 'Player 1':
                print("Player 1 Folds -> Player 2 is the winner")
                self.current_table.members[1].player.stack += table.pot
                print("Player 1 Stack:\t" + str(table.members[0].player.stack))
                print("Player 2 Stack:\t" + str(table.members[1].player.stack))
                winner = 2
                table.members[0].player.Game_Over(False, True,
                                                  total_games - game)
                table.members[1].player.Game_Over(True, True,
                                                  total_games - game)
            else:
                print("Player 2 Folds -> Player 1 is the winner")
                self.current_table.members[0].player.stack += table.pot
                print("Player 1 Stack:\t" + str(table.members[0].player.stack))
                print("Player 2 Stack:\t" + str(table.members[1].player.stack))
                winner = 1
                table.members[1].player.Game_Over(False, True,
                                                  total_games - game)
                table.members[0].player.Game_Over(True, True,
                                                  total_games - game)
            print(
                '--------------------------------------------------------------------------\n'
            )
            num_actions = len(table.members[0].actions) if len(
                table.members[0].actions) > 0 else 1
            #Uncomment to Write to GAME LOGS
            #self.Game_Summary(winner,table.pot,table.members[0].actions+"/"+table.members[1].actions,table.members[0].time_taken/num_actions,table.members[1].time_taken/num_actions,game)
            table.members[0].time_taken = 0
            table.members[1].time_taken = 0
            return winner
Example #4
0
        def Turn(dealer, non_dealer):
            table.big_blind = table.big_blind * 2
            drawn_cards = [deck.draw(1)]
            print("Turn:" + Card.print_pretty_cards(drawn_cards))

            for i in drawn_cards:
                self.board.append(i)
            for member in table.members:
                member.player.add_board(self.board)

            first_to_act = table.members[non_dealer]
            second_to_act = table.members[dealer]
            player_folded = Decisions([first_to_act, second_to_act], 2)
            return player_folded
Example #5
0
async def calculate_plo(web_client, user_id, channel_id):
    active_players = player_list[channel_id]
    tab = tab_list[channel_id]["table"]
    evaluator = Evaluator()

    for name in active_players:
        high = await find_best_plo_hand(name.name, channel_id)
        print(high, name.name)
        rank = evaluator.get_rank_class(high)
        name.cardswords = evaluator.class_to_string(rank)
        name.score = high

    for name in active_players:
        pic = Card.print_pretty_cards(name.cards)
        await sendslack("<@%s> shows %s" % (name.name, pic), web_client, channel_id)

    for name in active_players:
        await sendslack(
            "<@%s> has %s" % (name.name, name.cardswords), web_client, channel_id
        )

    if active_players[0].score < active_players[1].score:
        await sendslack(
            "<@%s> wins %d" % (active_players[0].name, tab.pot), web_client, channel_id
        )
        active_players[0].money += tab.pot

    else:
        await sendslack(
            "<@%s> wins %d" % (active_players[1].name, tab.pot), web_client, channel_id
        )
        active_players[1].money += tab.pot

    if len(active_players) > 1:
        if active_players[0].money != 0 and active_players[1].money != 0:
            if active_players[1].dealer:
                active_players += [active_players.pop(0)]

            tab.cards.clear()
            tab.turn = 0
            tab.highbet = 0
            tab.pot = 0
            for name in active_players:
                name.cards.clear()
                name.tocall = 0
                name.dealer = False
                name.bet = 0
                name.reraise = 0
                name.canclose = False
            await set_up_game(web_client, channel_id, plo=True)
Example #6
0
 def build_subtree(self, target_node, path):
     self.count += 1
     if type(target_node) == BeginNode:
         subpath = path + "\\Beginnode" + str(self.count)
     elif type(target_node) == CardNode:
         if target_node.board == "":
             subpath = path + "\\" + str([
                 Card.int_to_pretty_str(card) for card in target_node.hands
             ])
         elif len(target_node.board) == 3:
             subpath = path + "\\" + str([
                 Card.int_to_pretty_str(card) for card in target_node.board
             ])
         else:
             subpath = path + "\\" + Card.int_to_pretty_str(
                 target_node.board[-1])
     elif type(target_node) == ActionNode:
         subpath = path + "\\(" + action_to_str[
             target_node.label] + "," + action_to_str[
                 target_node.previous_action] + ")"
     else:
         subpath = path + "\\" + target_node.reason
     if os.path.exists(subpath) == False:
         os.mkdir(subpath)
     os.chdir(subpath)
     print(self.count, type(target_node))
     if type(target_node) == TerminalNode:
         with open("node info.txt", "w") as f:
             f.write(str(target_node))
     else:
         target_node.get_children()
         with open("node info.txt", "w") as f:
             f.write(str(target_node))
         if len(target_node.board) != "":
             Card.print_pretty_cards(target_node.board)
         for node in target_node.children:
             self.build_subtree(node, subpath)
Example #7
0
    def print_pretty_cards_on_table(self):
        """Input: cards, Output: pretty cards"""

        if self.cards_on_table != None:
            cards_list_with_ints = \
                self.convert_from_string_to_list(self.cards_on_table)
            output = Card.print_pretty_cards(cards_list_with_ints)

            # Change output from [9h], [6s], ... to 9h 6s ...
            output = output.replace("[", "")
            output = output.replace("]", "")
            output = output.replace(",", "")
            output = output.replace(" ", "")
            return output
        else:
            return ''
Example #8
0
    def test_print_pretty_cards_deck(self):
        """
        Input: String with cards separated by commas
        Output: Pretty cards as a string
        """

        # Arrange
        table = Table()
        table.deck = str(Card.new('As')) + ',' + str(Card.new('9h'))

        # Act
        table = table.print_pretty_cards_deck()
        cards_result = Card.print_pretty_cards(
            [Card.new('As'), Card.new('9h')])

        # Assertion
        self.assertEqual(table, cards_result)
        self.assertIsInstance(table, str)
Example #9
0
async def set_up_game(web_client, channel_id, plo=False):
    players = player_list[channel_id]
    if channel_id not in tab_list:
        deck = Deck()
        deck.shuffle()
        tab = Table()
        tab_list[channel_id] = {}
        tab_list[channel_id]["table"] = tab
        tab_list[channel_id]["deck"] = deck
    tab = tab_list[channel_id]["table"]
    deck = tab_list[channel_id]["deck"]
    deck.shuffle()
    tab.cards.extend(deck.draw(3))
    if plo:
        print("plos")
        tab.plo = True
    for name in players:
        if plo:
            name.cards.extend(deck.draw(4))
        else:
            print("nlhe")
            name.cards.extend(deck.draw(2))
        print("got to cards bit")
        pic = Card.print_pretty_cards(name.cards)
        await sendslack(pic, web_client, name.name)

    if len(players) == 2:
        i = random.randint(1, 2)
        if i == 1:
            players += [players.pop(0)]
        await start_heads_up(web_client, channel_id)

    if len(players) > 2:
        random.shuffle(players)
        tab.origlist = players.copy()
        await start_game(web_client, channel_id)
Example #10
0
# https://github.com/worldveil/deuces
# Treys is a Python 3 compatible version

from treys import Card
from treys import Evaluator
from treys import Deck

deck = Deck()
board = deck.draw(5)
p1 = deck.draw(2)
p2 = deck.draw(2)
p3 = deck.draw(2)
p4 = deck.draw(2)
p5 = deck.draw(2)

print(Card.print_pretty_cards(board))
print(Card.print_pretty_cards(p1))
print(Card.print_pretty_cards(p2))
print(Card.print_pretty_cards(p3))
print(Card.print_pretty_cards(p4))
print(Card.print_pretty_cards(p5))

evaluator = Evaluator()
p1_score = evaluator.evaluate(board, p1)
p2_score = evaluator.evaluate(board, p2)
p3_score = evaluator.evaluate(board, p3)
p4_score = evaluator.evaluate(board, p4)
p5_score = evaluator.evaluate(board, p5)
scores  = [p1_score,p2_score,p3_score,p4_score,p5_score]

p1_class = evaluator.get_rank_class(p1_score)
Example #11
0
File: go.py Project: amason13/treys
myhand.append(Card.new('3d'))
myhand.append(Card.new('4s'))
myhand.append(Card.new('5h'))
myhand.append(Card.new('As'))

print('Rank for A2345 is: ', evaluator.evaluate(myhand, []))

myhand = []
myhand.append(Card.new('Ac'))
myhand.append(Card.new('Kd'))
myhand.append(Card.new('Qs'))
myhand.append(Card.new('Jh'))
myhand.append(Card.new('Ts'))

print('Rank for AKQJT is: ', evaluator.evaluate(myhand, []))
'''
# create a card
card = Card.new('Qh')

# create a board and hole cards
board = [
    Card.new('2h'),
    Card.new('2s'),
    Card.new('Jc')
]
hand = [
    Card.new('Qs'),
    Card.new('Th')
]

# pretty print cards to console
Example #12
0
from treys import Card, Evaluator, Deck

# create a card
card = Card.new('Qh')

# create a board and hole cards
board = [Card.new('2h'), Card.new('2s'), Card.new('Jc')]
hand = [Card.new('Qs'), Card.new('Th')]

# pretty print cards to console
Card.print_pretty_cards(board + hand)

# create an evaluator
evaluator = Evaluator()

# and rank your hand
rank = evaluator.evaluate(board, hand)
print()
# or for random cards or games, create a deck
print("Dealing a new hand...")
deck = Deck()
board = deck.draw(5)
player1_hand = deck.draw(2)
player2_hand = deck.draw(2)

print("The board:")
Card.print_pretty_cards(board)

print("Player 1's cards:")
Card.print_pretty_cards(player1_hand)
Example #13
0
async def calculate_plo(web_client, user_id, channel_id):
    active_players = player_list[channel_id]
    tab = tab_list[channel_id]["table"]
    deck = tab_list[channel_id]["deck"]
    evaluator = Evaluator()
    allboard = await findsubsets(tab.cards, 3)
    p0allcard = await findsubsets(active_players[0].cards, 2)
    p1allcard = await findsubsets(active_players[1].cards, 2)
    boardlist = [list(x) for x in allboard]
    tmpp0list = [list(x) for x in p0allcard]
    tmpp1list = [list(x) for x in p1allcard]
    p0list = []
    p1list = []
    for i in boardlist:
        for j in tmpp0list:
            p0list.append(evaluator.evaluate(i, j))

    for i in boardlist:
        for j in tmpp1list:
            p1list.append(evaluator.evaluate(i, j))

    p0list.sort()
    p1list.sort()

    p0numhand = evaluator.get_rank_class(p0list[0])
    p0hand = evaluator.class_to_string(p0numhand)

    p1numhand = evaluator.get_rank_class(p1list[0])
    p1hand = evaluator.class_to_string(p1numhand)

    for p in active_players:
        pic = Card.print_pretty_cards(p.cards)
        await sendslack("<@%s> shows %s" % (p.name, pic), web_client, channel_id)

    await sendslack(
        "<@%s> has %s" % (active_players[0].name, p0hand), web_client, channel_id
    )
    await sendslack(
        "<@%s> has %s" % (active_players[1].name, p1hand), web_client, channel_id
    )

    if p0list[0] > p1list[0]:
        await sendslack(
            "<@%s> wins %d" % (active_players[0].name, tab.pot), web_client, channel_id
        )
        active_players[0].money += tab.pot
    else:
        await sendslack(
            "<@%s> wins %d" % (active_players[1].name, tab.pot), web_client, channel_id
        )
        active_players[1].money += tab.pot

    if len(active_players) == 2:
        if active_players[0].money != 0 and active_players[1].money != 0:
            if active_players[1].dealer:
                active_players += [active_players.pop(0)]

            tab.cards.clear()
            tab.turn = 0
            tab.highbet = 0
            tab.pot = 0
            for name in active_players:
                name.cards.clear()
                name.tocall = 0
                name.dealer = False
                name.bet = 0
            await set_up_game(web_client, channel_id, plo=True)
Example #14
0
# Takes a hand and board combination and evaluates it #

from treys import Card
from treys import Deck
from treys import Evaluator

board = [Card.new('Ah'), Card.new('Kd'), Card.new('Jc')]
hand = [Card.new('Qs'), Card.new('Th')]

print(Card.print_pretty_cards(board + hand))

# Hand strength is valued on a scale of 1 to 7462, where 1 is a Royal Flush and 7462 is unsuited 7-5-4-3-2
evaluator = Evaluator()
print(evaluator.evaluate(board, hand))
Example #15
0
    def PlayGame(self, no_of_games=1):
        #if self.current_table.is_full:
        current_game = 0
        while current_game < no_of_games:
            self.game_string = f'{str(current_game+1)}D{str(self.current_table.dealer_position)}P'
            game_round = 0  #0,1,2,3,4,5 -> Preflop,Flop,Turn,River,Postflop,Showdown
            deck = Deck()
            for member in self.current_table.members:
                member.cards = deck.draw(2)
                #Write Cards to Bot File
            while game_round < 6:
                if game_round == 0:
                    print("Pot:" + str(self.current_table.pot) + "\n")
                    #time.sleep(5)
                    decisions, player_folded = self.GetDecisions()
                    self.game_string += f'{decisions}'
                    self.UpdateGame()
                    if player_folded == -1:
                        game_round += 1

                    else:
                        game_round = 5
                if game_round == 1:
                    print("Pot:" + str(self.current_table.pot) + "\n")
                    drawn_cards = []
                    drawn_cards = deck.draw(3)
                    print("Flop:" + Card.print_pretty_cards(drawn_cards))
                    for i in drawn_cards:
                        self.board.append(i)
                        self.game_string += f'F{self.GetCardInt(i)}'
                    decisions, player_folded = self.GetDecisions()
                    self.game_string += f'F{decisions}'
                    self.UpdateGame()
                    if player_folded == True:
                        game_round = 5
                    else:
                        game_round += 1
                if game_round == 2:
                    print("Pot:" + str(self.current_table.pot) + "\n")
                    drawn_cards = [deck.draw(1)]
                    print("Turn:" + Card.print_pretty_cards(drawn_cards))
                    for i in drawn_cards:
                        self.board.append(i)
                        self.game_string += f'T{self.GetCardInt(i)}'
                    decisions, player_folded = self.GetDecisions()
                    self.game_string += f'T{decisions}'
                    self.UpdateGame()
                    if player_folded == True:
                        game_round = 5
                    else:
                        game_round += 1
                if game_round == 3:
                    print("Pot:" + str(self.current_table.pot) + "\n")
                    drawn_cards = [deck.draw(1)]
                    print("River:" + Card.print_pretty_cards(drawn_cards))
                    for i in drawn_cards:
                        self.board.append(i)
                        self.game_string += f'R{self.GetCardInt(i)}'
                    decisions, player_folded = self.GetDecisions()
                    self.game_string += f'R{decisions}'
                    self.UpdateGame()
                    if player_folded == True:
                        game_round = 5
                    else:
                        game_round += 1
                if game_round == 4:
                    print("Pot:" + str(self.current_table.pot) + "\n")
                    game_round += 1
                if game_round == 5:
                    if player_folded == -1:
                        for member in self.current_table.members:
                            self.game_string += f'S{member.seat_no}A{self.GetCardInt(member.cards[0])}B{self.GetCardInt(member.cards[1])}'
                        winner = self.Showdown()
                        self.game_string += f'W{winner}E'
                        self.UpdateGame()
                    else:
                        winner = self.Showdown(player_folded=(True,
                                                              player_folded))
                        self.game_string += f'W{winner}E'
                        self.UpdateGame()
                    game_round += 1
                    self.board = []
                    self.current_table.pot = 0
            no_of_games -= 1
Example #16
0
File: utils.py Project: LTS5/iapr
def print_game(game_dict, true_game):
    """
    Pretty prints the predicted game labels with the true game labels
    Parameters
    ----------
    game_dict : dict with the cards and chips detected for the game_id
    true_game : list of the cards and chips in the true game
    ----------
    Returns 
    None
    """
    #list to dict, with THOSE headers
    header_dict = [
        'T1', 'T2', 'T3', 'T4', 'T5', 'P11', 'P12', 'P21', 'P22', 'P31', 'P32',
        'P41', 'P42', 'CR', 'CG', 'CB', 'CK', 'CW'
    ]
    game = [game_dict[key] for key in header_dict]

    score, errors_game = eval_game(game_dict, true_game, verbose=False)

    def handle_empty(card):
        if card == '0' or card == 0:
            return None
        card2 = card[:-1] + card[-1:].lower()
        return Card.new(card2)

    def parse_pretty_hand(game):
        board = game[:5]
        all_players = [game[5 + i * 2:5 + (i + 1) * 2] for i in range(4)]
        chips = game[13:]

        board = [handle_empty(ci) for ci in board]
        hands = [[handle_empty(ci) for ci in pi] for pi in all_players]
        chips = [int(chip) for chip in chips]

        return hands, board, chips

    def print_hand(my_hand):
        #print(" --- " , my_hand)
        if my_hand[0] != None:
            print(Card.print_pretty_cards(my_hand))
        else:
            print(my_hand)

    hands_found, board_found, chips_found = parse_pretty_hand(game)
    hands_true, board_true, chips_true = parse_pretty_hand(true_game)

    #### Printing game begins

    #printing table cards
    print("__" * 20)

    print("Table ", end='')
    errors_table = errors_game[0:5]
    if np.sum(errors_table) != 0:

        print_color("mistakes in cards : ", 'red')
        print(list(np.where(errors_table)[0]))
        print("True table")
        print(Card.print_pretty_cards(board_true))
        print("Found table")
        print(Card.print_pretty_cards(board_found))
    else:
        print_color("found correctly", 'green')
        print("\n")
        print(Card.print_pretty_cards(board_found))
    print('\n')

    ##### Printing players cards
    ascii_check = ["---->", "xxxxx"]
    #ascii_circle = [🔴,🟢,🔵,⚫,⚪]
    ascii_circle = [0, 1, 2, 3, 4]
    errors_hands = errors_game[5:-5]
    for i in range(4):
        sum_error = np.sum(errors_hands[i * 2:(i + 1) * 2])
        right = ascii_check[0] if sum_error == 0 else ascii_check[1]
        if sum_error == 0:
            print_color(ascii_check[0], 'green')
        else:
            print_color(ascii_check[1], 'red')

        print(f"Player {i+1} ", end='')
        if sum_error == 0:
            print_color("found correctly", 'green')
            print_hand(hands_true[i])
        else:
            print_color("error", 'red')
            print("\n True hand")
            print_hand(hands_true[i])
            print("Estimated hand")
            print_hand(hands_found[i])
        print('\n')

    #### Printing chips
    chip_names = ['Red', 'Green', 'Blue', 'Black', 'White']
    chip_color = ['red', 'green', 'blue', 'black', 'white']
    for i in range(5):
        diff = chips_found[i] - chips_true[i]
        if diff == 0:
            print_color(ascii_check[0], "green")
        else:
            print_color(ascii_check[1], "red")
        print_color(f"Chip {chip_names[i]}", chip_color[i])
        print(f"\tfound: {chips_found[i]}. Count error: ( {diff} )", end='\n')

    print("__" * 20)
Example #17
0
        wm.add_watch(self.communication_files_directory, pyinotify.ALL_EVENTS, rec=True)

        # event handler
        kwargs = {"player_list": self.player_list}
        eh = MyEventHandler(**kwargs)

        # automate process of using bash
        # wd = os.getcwd()
        # #os.chdir("/usr/local/home/u180455/Desktop/Project/MLFYP_Project/MLFYP_Project/pokercasino")
        # os.chdir("/home/gary/Desktop/MLFYP_Project/MLFYP_Project/pokercasino")
        # subprocess.Popen("./lasvegas")
        # os.chdir(wd)

        # notifier
        notifier = pyinotify.Notifier(wm, eh)

        notifier.loop()



if __name__ == '__main__':
    treys_card.print_pretty_cards([268446761, 134236965, 33589533] + [67115551, 16787479])
    
    game = Game()
    # graphics = graphical_display.main_draw(game)





Example #18
0
        tops = ["\t" * self.num_tabs + self.ncol * '=']
        inner = ["\t" * self.num_tabs + '|' + " " *
                 (self.ncol - 2) + '|'] * (self.nrow - 2)

        rows = tops + inner + tops
        player_str = "{}, ${} in stack".format("Shyam", 10)

        middle = self.nrow // 2
        potstr = "pot: {}, side pot: {}".format(pot, side_pot)

        rows[middle - 1] = self.applyPadding(potstr, self.getPadding(potstr))
        rows[middle] = self.applyPadding(river_str, self.getPadding(river_str))

        return '\n' + round_str + '\n' + self.playerPadding(
            player_str, self.getPadding(
                player_str, 0.0)) + '\n' + '\n'.join(rows) + '\n' * 2

    def check(self):
        print("hey")


if __name__ == "__main__":
    from treys import Card

    board = [Card.new('Ah'), Card.new('Kd'), Card.new('Jc')]
    hand = [Card.new('Qs'), Card.new('Th')]

    p = Printer(15, 50)
    s = p.printBoard(1, Card.print_pretty_cards(board), pot=10)
    print(s)
Example #19
0
import random
from treys import Card, Deck, Evaluator

evaluator = Evaluator()
deck = Deck()

print("1v1 Texas Hold'em")

# Draw flop, turn, and river respectively
flop = deck.draw(3)
turn = deck.draw(1)
river = deck.draw(1)
board = flop + [turn] + [river]

hand1 = deck.draw(2)
hand2 = deck.draw(2)
hands = [hand1, hand2]

print("Board:", Card.print_pretty_cards(board))
evaluator.evaluate(board, hand1)

print("Summary:")
evaluator.hand_summary(board, hands)
    # [J♦],[6♦]
    # Board card:
    # [7♣],[3♣],[A♦]
    # hole = [getCard('Jd'), getCard('6d')]
    # boards = [getCard('7c'), getCard('3c'), getCard('Ad')]
    # print("Hole:")
    # Card.print_pretty_cards(hole)
    # print("Boards:")
    # Card.print_pretty_cards(boards)
    # print("Draw:")
    # drawCard, rate = CardCounting().evaluate(hole, boards, 0.75)
    # Card.print_pretty_cards(drawCard)

    hole = [getCard('5s'), getCard('5h')]
    pot = []
    HoleEvaluator().evaluate(hole, 3, 1000)

    drawCard.clear()
    hole = [getCard('As'), getCard('9c')]
    boards = [getCard('Qc'), getCard('6c'), getCard('9d'), getCard('6d')]
    drawCard, rate = CardCounting().evaluate(hole, boards, 0.6)
    Card.print_pretty_cards(drawCard)
    print('rate:{:2.2%}'.format(rate))

    drawCard.clear()
    hole = [getCard('5d'), getCard('Qc')]
    boards = [getCard('2d'), getCard('Td'), getCard('Kc'), getCard('Jc')]
    drawCard, rate = CardCounting().evaluate(hole, boards, 0.6)
    Card.print_pretty_cards(drawCard)
    print('rate:{:2.2%}'.format(rate))
Example #21
0
        action = random.randint(0, 31)

    new_eval = draw_until_empty_reward_mean(hand, action)
    reward = get_reward(new_eval)
    current_metric_score += reward
    if (i+1) % metrics_window == 0:
        metrics_score.append(current_metric_score/metrics_window)
        current_metric_score = 0
    train_X.append(feat.reshape((61,)))

    Q[0, action] = reward
    train_Y.append(Q.reshape((32,)))
    if (i+1) % train_steps == 0:
        print("hand n° ", str(i))
        print("random %", str(epsi))
        print(Card.print_pretty_cards(old_hand))
        print(map_to_draw(np.argmax(Q)))
        print(Card.print_pretty_cards(hand))
        print(Q)
        model.fit(np.stack(train_X), np.stack(train_Y), verbose=1, epochs=5)

        # reduce explo
        epsi *= 0.9

    if len(train_X) > max_replay:
        train_X = train_X[50:]
        train_Y = train_Y[50:]

print(metrics_score)
print("Saving model..")
model.save('models/modelremade.h5')
Example #22
0
async def bet_to_close(web_client, user_id, channel_id, bet):
    active_players = player_list[channel_id]
    tab = tab_list[channel_id]["table"]
    deck = tab_list[channel_id]["deck"]
    if bet == tab.highbet:

        print("betwixt")
        tab.pot += bet
        active_players[0].money = active_players[0].money - bet
        print(active_players[0].money, "active")
        print(active_players[1].money, "notactive")
        if tab.turn == 0:
            print("stage5")
            tabcards = Card.print_pretty_cards(tab.cards)
            await sendslack(
                "<@%s> calls. dealing flop:" % user_id, web_client, channel_id
            )
            await sendslack(tabcards, web_client, channel_id)
            if active_players[0].dealer:
                active_players += [active_players.pop(0)]

            await sendslack(
                "<@%s> is next to act" % active_players[0].name, web_client, channel_id
            )
            await sendslack("pot is %s" % tab.pot, web_client, channel_id)
            for name in active_players:
                name.bet = 0
                name.tocall = 0
                name.reraise = 0
            tab.turn += 1
            tab.highbet = 0
            active_players[0].canclose = False
            active_players[1].canclose = True

        elif tab.turn == 1:
            print("stage6")
            tab.cards.append(deck.draw(1))
            print(tab_list[channel_id]["table"].cards)
            tabcards = Card.print_pretty_cards(tab.cards)
            await sendslack(
                "<@%s> calls. dealing turn:" % user_id, web_client, channel_id
            )
            await sendslack(tabcards, web_client, channel_id)
            if active_players[0].dealer:
                active_players += [active_players.pop(0)]

            await sendslack(
                "<@%s> is next to act" % active_players[0].name, web_client, channel_id
            )
            await sendslack("pot is %s" % tab.pot, web_client, channel_id)
            for name in active_players:
                name.bet = 0
                name.tocall = 0
                name.reraise = 0
            tab.turn += 1
            tab.highbet = 0
            active_players[0].canclose = False
            active_players[1].canclose = True

        elif tab.turn == 2:
            print("stage7")
            tab.cards.append(deck.draw(1))
            print(tab.cards)
            tabcards = Card.print_pretty_cards(tab.cards)
            await sendslack(
                "<@%s> calls. dealing river:" % user_id, web_client, channel_id
            )
            await sendslack(tabcards, web_client, channel_id)
            if active_players[0].dealer:
                active_players += [active_players.pop(0)]

            await sendslack(
                "<@%s> is next to act" % active_players[0].name, web_client, channel_id
            )
            await sendslack("pot is %s" % tab.pot, web_client, channel_id)

            for name in active_players:
                name.bet = 0
                name.tocall = 0
                name.reraise = 0
            tab.turn += 1
            tab.highbet = 0
            active_players[0].canclose = False
            active_players[1].canclose = True

        elif tab.turn == 3:
            await sendslack("<@%s> calls." % user_id, web_client, channel_id)
            tabcards = Card.print_pretty_cards(tab.cards)
            await sendslack(tabcards, web_client, channel_id)
            if tab.plo == True:
                await calculate_plo(web_client, user_id, channel_id)
            else:
                # players = player_list[channel_id]
                evaluator = Evaluator()
                scores = {}
                for p in active_players:
                    pic = Card.print_pretty_cards(p.cards)
                    await sendslack(
                        "<@%s> has %s" % (p.name, pic), web_client, channel_id
                    )
                    scores[evaluator.evaluate(tab.cards, p.cards)] = p
                    p.cards = []

                d = OrderedDict(sorted(scores.items(), key=lambda t: t[0]))
                items = list(d.items())
                for i in items:
                    print(i, "herewith")
                    p_score = i[0]
                    p_class = evaluator.get_rank_class(p_score)
                    hand = evaluator.class_to_string(p_class)
                    await sendslack(
                        "<@%s> has %s" % (i[1].name, hand), web_client, channel_id
                    )
                winner = [x for x in items if x[0] == items[0][0]]

                for p in winner:
                    await sendslack(
                        "<@%s> won and got %d" % (p[1].name, tab.pot),
                        web_client,
                        channel_id,
                    )
                    for name in active_players:
                        if name.name == p[1].name:
                            name.money += tab.pot

                if len(active_players) == 2:
                    if active_players[0].money != 0 and active_players[1].money != 0:
                        if active_players[1].dealer:
                            active_players += [active_players.pop(0)]

                        tab.cards.clear()
                        tab.turn = 0
                        tab.highbet = 0
                        tab.pot = 0
                        for name in active_players:
                            name.cards.clear()
                            name.tocall = 0
                            name.dealer = False
                            name.bet = 0
                            name.reraise = 0
                            name.canclose = False
                        await set_up_game(web_client, channel_id)
Example #23
0
File: utils.py Project: LTS5/iapr
 def print_hand(my_hand):
     #print(" --- " , my_hand)
     if my_hand[0] != None:
         print(Card.print_pretty_cards(my_hand))
     else:
         print(my_hand)
Example #24
0
    def get_win_prob(self, state, playerid):
        """Calculate the win probability from your board cards and hand cards by using simple Monte Carlo method.
        """
        evaluator = Evaluator()

        def get_card_class(card_int_list):
            res = [
                Card.new(Card.int_to_str(c)) for c in card_int_list if c != -1
            ]
            return res

        def WinProbability(hand, board):
            rank = evaluator.evaluate(board, hand)
            percentage = 1.0 - evaluator.get_five_card_rank_percentage(rank)
            return percentage

        hand_cards = get_card_class(state.player_states[playerid].hand)
        board_cards = get_card_class(state.community_card)
        if any([True for h in hand_cards if h in board_cards]):
            Card.print_pretty_cards(hand_cards)
            Card.print_pretty_cards(board_cards)
        num_players = len(
            [p for p in state.player_states if not p.emptyplayer])

        win = 0
        round = 0

        board_cards_to_draw = 5 - len(board_cards)  # 2
        rest_cards = self._pick_unused_card(board_cards + hand_cards)
        #print("rest cards")
        #Card.print_pretty_cards(rest_cards)

        #choiced = random.sample(unused, card_num)

        for i in range(self.simulation_number):

            unused_cards = random.sample(rest_cards, (num_players - 1) * 2 +
                                         board_cards_to_draw)
            board_sample = unused_cards[len(unused_cards) -
                                        board_cards_to_draw:]
            unused_cards = unused_cards[:len(unused_cards) -
                                        board_cards_to_draw]

            opponents_hole = [
                unused_cards[2 * i:2 * i + 2] for i in range(num_players - 1)
            ]

            try:
                opponents_score = [
                    WinProbability(hole, board_sample)
                    for hole in opponents_hole
                ]
                my_rank = WinProbability(hand_cards, board_sample)
                if my_rank >= max(opponents_score):
                    win += 1
                round += 1
            except Exception as inst:  # Exception, e:
                #print e.message
                continue
        #print("Win:{}".format(win))
        #print('round:{}'.format(round))
        if round == 0:
            if len(board_cards) > 1:
                try:
                    return WinProbability(board_cards, hand_cards)
                except:
                    return 0.6
            else:
                return 0.6
        win_prob = win / float(round)
        return win_prob
def evaluateCards(boardCards, handCards):
    # decrypt the two hand cards sent from the client + board cards
    n = 2
    str(boardCards).lower()
    boardCardsSplit = [(boardCards[i:i + n])
                       for i in range(0, len(boardCards), n)]

    str(handCards).lower()
    handCardsSplit = [(handCards[i:i + n])
                      for i in range(0, len(handCards), n)]

    handCardsSplit[0] = handCardsSplit[0][1] + handCardsSplit[0][0]
    handCardsSplit[1] = handCardsSplit[1][1] + handCardsSplit[1][0]

    hand = [
        Card.new(str(handCardsSplit[0].capitalize())),
        Card.new(str(handCardsSplit[1].capitalize()))
    ]
    board = []
    i = 0
    if len(list(boardCardsSplit)) == 3:
        board = [
            Card.new(str(boardCardsSplit[0].capitalize())),
            Card.new(str(boardCardsSplit[1].capitalize())),
            Card.new(str(boardCardsSplit[2].capitalize()))
        ]
    else:
        if len(list(boardCardsSplit)) == 4:
            board = [
                Card.new(str(boardCardsSplit[0].capitalize())),
                Card.new(str(boardCardsSplit[1].capitalize())),
                Card.new(str(boardCardsSplit[2].capitalize())),
                Card.new(str(boardCardsSplit[3].capitalize()))
            ]
        else:
            if len(list(boardCardsSplit)) == 5:
                board = [
                    Card.new(str(boardCardsSplit[0].capitalize())),
                    Card.new(str(boardCardsSplit[1].capitalize())),
                    Card.new(str(boardCardsSplit[2].capitalize())),
                    Card.new(str(boardCardsSplit[3].capitalize())),
                    Card.new(str(boardCardsSplit[4].capitalize()))
                ]

    deck = Deck()
    print(Card.print_pretty_cards(board + hand))

    evaluator = Evaluator()
    bestScore = evaluator.evaluate(board, hand)
    handType = evaluator.get_rank_class(bestScore)

    print("Player 1 hand rank = %d (%s)\n" %
          (bestScore, evaluator.class_to_string(handType)))

    if (len(board) == 5):
        for i in range(len(board) + len(hand)):
            # Make copy of hand and board
            tempHand = []
            tempBoard = []
            for j in range(len(hand)):
                tempHand.append(hand[j])
            for j in range(len(board)):
                tempBoard.append(board[j])

            #First try removing one of the hand cards
            if (i < 2):
                tempHand.pop(i)
                tempHand.append(board[0])
                tempBoard.pop(0)
            #Now we try removing board cards
            else:
                tempBoard.pop(i - 2)

            #Find the score
            score = evaluator.evaluate(tempBoard, tempHand)
            #If score is same as before, these cards have the best hand
            if (score == bestScore):
                # Make copy of best hand and board
                best6Hand = []
                best6Board = []
                for j in range(len(tempHand)):
                    best6Hand.append(tempHand[j])
                for j in range(len(tempBoard)):
                    best6Board.append(tempBoard[j])
                break
    else:
        best6Board = board
        best6Hand = hand

    print(Card.print_pretty_cards(best6Board + best6Hand))

    if (len(best6Board) == 4 or len(board) == 4):
        #we repeat the process to have the best 5 cards
        for i in range(len(best6Board) + len(best6Hand)):
            #Make copy of hand and board
            tempHand = []
            tempBoard = []
            for j in range(len(best6Hand)):
                tempHand.append(best6Hand[j])
            for j in range(len(best6Board)):
                tempBoard.append(best6Board[j])

            if (i < 2):
                tempHand.pop(i)
                tempHand.append(best6Board[0])
                tempBoard.pop(0)
            else:
                tempBoard.pop(i - 2)
            score = evaluator.evaluate(tempBoard, tempHand)
            if (score == bestScore):
                # Make copy of best hand and board
                best5Hand = []
                best5Board = []
                for j in range(len(tempHand)):
                    best5Hand.append(tempHand[j])
                for j in range(len(tempBoard)):
                    best5Board.append(tempBoard[j])
                break

    else:
        best5Board = best6Board
        best5Hand = best6Hand

    print(Card.print_pretty_cards(best5Board + best5Hand))

    card1 = convertCardToString(best5Board.__getitem__(0))
    card2 = convertCardToString(best5Board.__getitem__(1))
    card3 = convertCardToString(best5Board.__getitem__(2))
    card4 = convertCardToString(best5Hand.__getitem__(0))
    card5 = convertCardToString(best5Hand.__getitem__(1))

    handString = card1 + card2 + card3 + card4 + card5
    print("Hand string:  " + handString)

    stringToSend = str(handType) + " " + handString + " " + str(bestScore)

    print("String to send:  " + stringToSend)

    return stringToSend
Example #26
0
        return 0


#input is single card and single swap
#helper function for make_swaps
def do_swap(card, swap):

    char_one = swap[0]
    char_two = swap[1]

    if (Card.get_suit_int(card) == char_to_int[char_one]):
        return Card.new(rank_int_to_char[Card.get_rank_int(card)] + char_two)
    else:
        return card


#EXAMPLES
hand = []
hand.append(Card.new("4c"))
hand.append(Card.new("Ac"))

print("Original hand: ")
Card.print_pretty_cards(hand)

s = find_swap(hand)
new_hand = make_swaps(hand, s)

if (new_hand != 0):
    print("\nNew hand: ")
    Card.print_pretty_cards(new_hand)
Example #27
0
    def process_IN_CLOSE_WRITE(self, event):
        ### declaring a bot_number and event_type 
        #print("IN_CLOSE_WRITE event:", event.pathname)
        
        global file_changed
        arr = re.split(r'[/]',event.pathname)
        most_recent_file_changed = (arr[len(arr)-1]) # last string in file path
        last_letter = most_recent_file_changed[len(most_recent_file_changed)-1]
        bot_number = last_letter if (last_letter =='0' or last_letter == '1' or last_letter == '2') else ''
        event_type = most_recent_file_changed if bot_number == '' else most_recent_file_changed[0:len(most_recent_file_changed)-1]
        filename = str(event_type+bot_number)
        file_data = get_status_from_file(str(filename))
        if event_type == "give_hand_bot":

            if bot_number == '0':
                self.player_list[0].card_holding = llf.GHB_Parsing(self.player_list[0], file_data) #check cards
                #PROBLEM: Cannot evaluate preflop without players position which is retrieved in casinoToBot file overwrite
                #he, evaluation, rc, score_desc, _ = self.player_list[0].hand_evaluate_preflop(self.player_list[0].card_holding, self.player_list[0].name)
                # bot 0 now has his cards

            elif bot_number == '1':
                self.player_list[1].card_holding = llf.GHB_Parsing(self.player_list[1], file_data) #check cards
                #print(self.player_list[0].card_holding)

                #PROBLEM: Cannot evaluate preflop without players position which is retrieved in casinoToBot file overwrite
                #he, evaluation, rc, score_desc, _ = self.player_list[1].hand_evaluate_preflop(self.player_list[1].card_holding, self.player_list[1].name)

                #bot 1 now has his cards
            
            elif bot_number == '2':
                self.player_list[2].card_holding = llf.GHB_Parsing(self.player_list[2], file_data) #check cards
                #print(self.player_list[0].card_holding)

                #PROBLEM: Cannot evaluate preflop without players position which is retrieved in casinoToBot file overwrite
                #he, evaluation, rc, score_desc, _ = self.player_list[1].hand_evaluate_preflop(self.player_list[1].card_holding, self.player_list[1].name)

                #bot 1 now has his cards    

        elif event_type == "casinoToBot":   # only on (second) iteration, is the casinoToBOT file written with the actions ie 'rrc'
            treys_card.print_pretty_cards([268446761, 134236965, 33589533] + [67115551, 16787479])
            with open("./test_file_data_change_CTB", 'a+') as f:
                f.write("\n"+file_data)
                f.close()
            ctb_file_content =  re.split(r'[DPFFFFTTRRSABSABWWE]',file_data) # DEBUG: test_file_data
            dealer_no = ctb_file_content[1]
            # casinoToBot is written: hand number> D <dealer button position> P <action by all players in order from first to act, e.g. fccrf...> F <flop card 1> F <flop 2> F <flop 3> F <flop action starting with first player to act>
            #  T <turn card> T <turn action> R <river card> R <river action>
            
            bot_n = int(bot_number)
            bot_cards = self.player_list[bot_n].card_holding
            bot_name = self.player_list[bot_n].name
            
            # we want to check if ONLY the preflop action is filled
            is_preflop_action_filled, is_flop_action_filled, is_turn_action_filled, is_river_action_filled = llf.casinoToBot_ParsingRead(self, ctb_file_content, self.player_list[bot_n], self.player_list, bot_number) # DEBUG: test_file_data #check cards
            flop_cards_present, turn_card_present, river_card_present = llf.check_cards_shown(file_data)
            first_meeting = {0: False, 1: False, 2: False, 3: False}
            is_new_game = False
            
            # PREFLOP
            if (flop_cards_present == False and turn_card_present == False and river_card_present == False):
                
                # first move (BTN)
                if(is_preflop_action_filled == False and is_flop_action_filled == False and is_turn_action_filled ==False and is_river_action_filled == False): # is only preflop filled?                he, evaluation, rc, score_desc, player_action = self.player_list[bot_n].hand_evaluate_preflop(bot_cards, bot_name)   # USE FOR DEBUGGING (files have alreayd been filled with debugger)
                    
                    for player in self.player_list:
                        player.is_new_game = True
                    first_meeting[0] = True
                    he, rc, score_desc, player_action = self.player_list[bot_n].hand_evaluate(bot_cards, bot_name, 'Preflop', first_meeting, True)   # USE FOR DEBUGGING (files have alreayd been filled with debugger)
                    self.player_list[bot_n].is_new_game = False
                    
                elif(is_preflop_action_filled == True and is_flop_action_filled == False and is_turn_action_filled ==False and is_river_action_filled == False): # is flop filled yet?

                    first_meeting[0] = False
                    he, rc, score_desc, player_action = self.player_list[bot_n].hand_evaluate(bot_cards, bot_name, 'Preflop', first_meeting, False)   # USE FOR DEBUGGING (files have alreayd been filled with debugger)
                    self.player_list[bot_n].is_new_game = False

            #POSTFLOP
            elif (flop_cards_present == True and turn_card_present == False and river_card_present == False):
                              
                #first move of flop (SB assuming he hasn't folded)
                if(is_preflop_action_filled == True and is_flop_action_filled == False and is_turn_action_filled ==False and is_river_action_filled == False): # is flop filled yet?
                    first_meeting[1] = True
                    self.player_list[bot_n].action_sent = False
                    he, rc, score_desc, player_action = self.player_list[bot_n].hand_evaluate(bot_cards, bot_name, 'Flop', first_meeting, False)    # USE FOR DEBUGGING (files have alreayd been filled with debugger)

                elif(is_preflop_action_filled == True and is_flop_action_filled == True and is_turn_action_filled ==False and is_river_action_filled == False): # is turn filled yet?
                    first_meeting[1] = False
                    self.player_list[bot_n].action_sent = False
                    he, rc, score_desc, player_action = self.player_list[bot_n].hand_evaluate(bot_cards, bot_name, 'Flop', first_meeting, False)   # USE FOR DEBUGGING (files have alreayd been filled with debugger)
                
            #TURN
            elif (flop_cards_present == True and turn_card_present == True and river_card_present == False):
                #print("inside TURN main")
                #print("\n", is_preflop_action_filled, is_flop_action_filled, is_turn_action_filled, is_river_action_filled)
                # first move of turn
                if(is_turn_action_filled ==False and is_river_action_filled == False): # is turn filled yet?
                    #print("inside TURN 1")
                    first_meeting[2] = True
                    self.player_list[bot_n].action_sent = False
                    he, rc, score_desc, player_action = self.player_list[bot_n].hand_evaluate(bot_cards, bot_name, 'Turn', first_meeting, False)  # USE FOR DEBUGGING (files have alreayd been filled with debugger)

                elif(is_turn_action_filled ==True and is_river_action_filled == False): #is river filled yet?
                    #print("inside TURN 2")
                    first_meeting[2] = False
                    self.player_list[bot_n].action_sent = False
                    he, rc, score_desc, player_action = self.player_list[bot_n].hand_evaluate(bot_cards, bot_name, 'Turn', first_meeting, False)    # USE FOR DEBUGGING (files have alreayd been filled with debugger)

            #RIVER
            elif (flop_cards_present == True and turn_card_present == True and river_card_present == True):

                # first move of river
                if(is_preflop_action_filled == True and is_flop_action_filled == True and is_turn_action_filled ==True and is_river_action_filled == False): #is river filled yet?
                    first_meeting[3] = True
                    self.player_list[bot_n].action_sent = False
                    he, rc, score_desc, player_action = self.player_list[bot_n].hand_evaluate(bot_cards, bot_name, 'River', first_meeting, False)   # USE FOR DEBUGGING (files have alreayd been filled with debugger)

                elif(is_preflop_action_filled == True and is_flop_action_filled == True and is_turn_action_filled ==True and is_river_action_filled == True): #is river filled yet?
                    first_meeting[3] = False
                    self.player_list[bot_n].action_sent = False
                    he, rc, score_desc, player_action = self.player_list[bot_n].hand_evaluate(bot_cards, bot_name, 'River', first_meeting, False)    # USE FOR DEBUGGING (files have alreayd been filled with debugger)
    def play_game_human_human(self):
        """Rollout one OFC game and return the LHS score and LHS/RHS boards."""
        deck = DeckGenerator.new_deck()

        lhs_board = OFCBoard()
        rhs_board = OFCBoard()

        lhs_start = deck[0:5]
        rhs_start = deck[6:11]

        # Starting hand one card at a time for now. In future, give
        # all cards at once
        lhs_board.pretty()
        print('Player 1 starting cards;'),
        Card.print_pretty_cards([Card.new(card) for card in lhs_start])
        for i in range(5):
            card = lhs_start[i]
            street_id = self.lhs_agent.place_new_card(card, lhs_board)
            lhs_board.place_card_by_id(card, street_id)
            lhs_board.pretty()

        rhs_board.pretty()
        print('Player 2 starting cards;'),
        Card.print_pretty_cards([Card.new(card) for card in rhs_start])
        for i in range(5):
            card = rhs_start[i]
            street_id = self.rhs_agent.place_new_card(card, rhs_board)
            rhs_board.place_card_by_id(card, street_id)
            rhs_board.pretty()

        # Eight cards one at a time
        for i in range(8):
            self.print_both_boards(lhs_board, rhs_board)
            card = deck.pop()
            street_id = self.lhs_agent.place_new_card(card, lhs_board)
            lhs_board.place_card_by_id(card, street_id)

            self.print_both_boards(lhs_board, rhs_board)
            card = deck.pop()
            street_id = self.rhs_agent.place_new_card(card, rhs_board)
            rhs_board.place_card_by_id(card, street_id)

        print('Final Boards')
        self.print_both_boards(lhs_board, rhs_board)

        lhs_royalties = lhs_board.get_royalties()
        rhs_royalties = rhs_board.get_royalties()

        if lhs_board.is_foul() and rhs_board.is_foul():
            lhs_score = 0

        elif lhs_board.is_foul():
            lhs_score = (-1 * rhs_royalties) - 6

        elif rhs_board.is_foul():
            lhs_score = lhs_royalties + 6

        else:
            exch = self.calculate_scoop(lhs_board, rhs_board)
            lhs_score = exch + lhs_royalties - rhs_royalties

        return lhs_score, lhs_board, rhs_board