示例#1
0
    def evaluateFromState(self, state, playerid):
        # print("state",state.player_states[playerid].hand) 
        evaluator = Evaluator()
        hand = []
        board = []
        # p1_score = evaluator.evaluate(board, player1_hand)
        for i in state.player_states[playerid].hand:
            hand.append(Card.new(card_to_normal_str(i)))
            # print(card_to_normal_str(i))
            # print(hand)

        for j in state.community_card:
            if j != -1:
                # print(card_to_normal_str(j))
                board.append(Card.new(card_to_normal_str(j)))
                # print(board)

        if len(board) == 0:
            rank = evaluator.evaluate(hand, [])
        elif len(board) == 3: 
            rank = evaluator.evaluate(hand, board[:3])
        elif len(board) == 4:
            rank = evaluator.evaluate(hand, board[:4])
        elif len(board) == 5:
            rank = evaluator.evaluate(hand, board[:5])
        rank_class = evaluator.get_rank_class(rank)
        class_string = evaluator.class_to_string(rank_class)
        percentage = 1.0 - evaluator.get_five_card_rank_percentage(rank)  # higher better here
        return [rank,percentage]
示例#2
0
def evaluate(hand, board):
    try:
        board = card_parser(board)
        hand = card_parser(hand)
        evaluator = Evaluator()
        strength = evaluator.evaluate(board, hand)
        rank = evaluator.class_to_string(evaluator.get_rank_class(strength))
        return jsonify(dict(rank=rank, strength=strength))
    except (IndexError, KeyError):
        return "Check your syntax!"
示例#3
0
from evaluator import Evaluator
from card import Card
from util import Util
evaluator = Evaluator()
util = Util()
average_range= set()
for set_ in Util.PAIRS.values():
    average_range |= set_

average_range |= (Util.UNSUITED['AK'] | Util.UNSUITED['K8'] | 
                 Util.UNSUITED['AQ'] | Util.UNSUITED['QJ'] | 
                 Util.UNSUITED['AJ'] | Util.UNSUITED['QT'] | 
                 Util.UNSUITED['AT'] | 
                 Util.UNSUITED['A9'] | 
                 Util.UNSUITED['A8'] | 
                 Util.UNSUITED['KQ'] | 
                 Util.UNSUITED['KJ'] | 
                 Util.UNSUITED['T9'])

hole_cards = list(map(Card.new, ['Ah', 'Jd']))
community_cards = list(map(Card.new, ['2c', 'Qh', '9d']))
print("hole_cards     ", " ".join(Card.int_to_pretty_str(card) for card in hole_cards))
print("community_cards", " ".join(Card.int_to_pretty_str(card) for card in community_cards))
print("all_cards      ", " ".join(Card.int_to_pretty_str(card) for card in hole_cards + community_cards))

score = evaluator.evaluate(hole_cards, community_cards)
print("score", score)
print("rank", evaluator.class_to_string(evaluator.get_rank_class(score)))

print(util.my_equity(tuple(hole_cards), tuple(community_cards), average_range))