Exemple #1
0
        def _extract_features(records):
            # "Deal", "Flop", "Turn", "River": 0, 1, 2, 3
            privateCards = [
                Card(card).serial for card in records["privateCards"]
            ]

            deal_round = [
                round_seq,
                raiseCount[0],
                betCount[0],
                privateCards[0],
                privateCards[1],
                0,
                0,
                0,
                0,
                0,  # public card
                0,  # card ranking
            ]
            #+ [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] # card histogram

            flop_round = [round_seq, raiseCount[1], betCount[1],
                          privateCards[0], privateCards[1],
                          publicCards[0],
                          publicCards[1],
                          publicCards[2],
                          0,
                          0,
                          Card.get_card_suite(table_info["publicCards"][0:3], records["privateCards"])
                          ] \
                          if round_seq >= 1 else \
                          [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]# + [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] # card histogram
            #+ holdem_cal(records["privateCards"], table_info["publicCards"][0:3])[0] \

            turn_round = [round_seq, raiseCount[2], betCount[2],
                          privateCards[0], privateCards[1],
                          publicCards[0],
                          publicCards[1],
                          publicCards[2],
                          publicCards[3], 0,
                          Card.get_card_suite(table_info["publicCards"][0:4], records["privateCards"]),
                          ] \
                          if round_seq >= 2 else \
                          [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]# + [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] # card histogram
            #+ holdem_cal(records["privateCards"], table_info["publicCards"][0:4])[0] \


            river_round = [round_seq, raiseCount[3], betCount[3],
                          privateCards[0],
                          privateCards[1],
                          publicCards[0],
                          publicCards[1],
                          publicCards[2],
                          publicCards[3],
                          publicCards[4],
                          Card.get_card_suite(table_info["publicCards"][0:5], records["privateCards"]),
                          ] \
                          if round_seq == 3 else \
                          [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]# + [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] # card histogram
            #+ holdem_cal(records["privateCards"], table_info["publicCards"][0:5])[0] \

            return [deal_round, flop_round, turn_round, river_round]
Exemple #2
0
    def get_features(self, table_info, round_seq):
        ############################################
        # roundName, raiseCount, betCount,privateCards, publicCards, evaluate,  histogram
        #   0      ,    1      , 2       , 1, 23      , 1, 2, 4, 0,0,  7624, TBD
        #   0.0, 0.0, 0.9130434782608695, 0.0, 0.0, 0.0, 0.08695652173913043, 0.0, 0.0, 0.0, 1, 11, 22, 33, 44, 55
        ##############

        ###### card Histogram
        # High Card :  0.0
        # Pair :  0.0
        # Two Pair :  0.913043478261
        # Three of a Kind :  0.0
        # Straight :  0.0
        # Flush :  0.0
        # Full House :  0.0869565217391
        # Four of a Kind :  0.0
        # Straight Flush :  0.0
        # Royal Flush :  0.0
        #######################

        #numPlayers = table_info["numPlayers"]

        if not table_info:
            return None

        raiseCount = table_info["raiseCount"]
        betCount = table_info["betCount"]
        publicCards = [Card(card).serial for card in table_info["publicCards"]]

        def _extract_features(records):
            # "Deal", "Flop", "Turn", "River": 0, 1, 2, 3
            privateCards = [
                Card(card).serial for card in records["privateCards"]
            ]

            deal_round = [
                round_seq,
                raiseCount[0],
                betCount[0],
                privateCards[0],
                privateCards[1],
                0,
                0,
                0,
                0,
                0,  # public card
                0,  # card ranking
            ]
            #+ [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] # card histogram

            flop_round = [round_seq, raiseCount[1], betCount[1],
                          privateCards[0], privateCards[1],
                          publicCards[0],
                          publicCards[1],
                          publicCards[2],
                          0,
                          0,
                          Card.get_card_suite(table_info["publicCards"][0:3], records["privateCards"])
                          ] \
                          if round_seq >= 1 else \
                          [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]# + [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] # card histogram
            #+ holdem_cal(records["privateCards"], table_info["publicCards"][0:3])[0] \

            turn_round = [round_seq, raiseCount[2], betCount[2],
                          privateCards[0], privateCards[1],
                          publicCards[0],
                          publicCards[1],
                          publicCards[2],
                          publicCards[3], 0,
                          Card.get_card_suite(table_info["publicCards"][0:4], records["privateCards"]),
                          ] \
                          if round_seq >= 2 else \
                          [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]# + [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] # card histogram
            #+ holdem_cal(records["privateCards"], table_info["publicCards"][0:4])[0] \


            river_round = [round_seq, raiseCount[3], betCount[3],
                          privateCards[0],
                          privateCards[1],
                          publicCards[0],
                          publicCards[1],
                          publicCards[2],
                          publicCards[3],
                          publicCards[4],
                          Card.get_card_suite(table_info["publicCards"][0:5], records["privateCards"]),
                          ] \
                          if round_seq == 3 else \
                          [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]# + [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] # card histogram
            #+ holdem_cal(records["privateCards"], table_info["publicCards"][0:5])[0] \

            return [deal_round, flop_round, turn_round, river_round]

        results = []

        # not found the winner in this game, it is possible the winner has no private cards
        if "winner" not in table_info:
            return results

        # add winer into the 1st
        results.append(
            _extract_features(self.player_records[table_info["winner"]][
                table_info["tableNo"]]))

        # add the loser
        for player in table_info["player"]:
            if player == table_info["winner"]:
                continue
            elif player not in self.player_records:
                continue
            player_rec = self.player_records[player]
            if table_info["tableNo"] not in player_rec:
                continue
            results.append(
                _extract_features(
                    self.player_records[player][table_info["tableNo"]]))

        return results