outs held $\to$ desired odds
2 pair $\to$ trips 4
4 two pair $\to$ full house 8
4 gut shot $\to$ straight 8
6 overcards $\to$ pair 12
8 open-ended straight $\to$ straight 16
9 four flush $\to$ flush 18
15 straight & flush draw $\to$ straight or flush 30

In [56]:
def stella(outs, pot, bet):
    return 'call' if (2 * outs) > (bet / (pot + bet) * 100) else 'fold'

In [57]:
# outs pot bet
stella(6,1725,400)


Out[57]:
'fold'

In [58]:
def pot_equity(pot, bet):
    return round(bet / (pot + bet) * 100)

In [59]:
pot_equity(300, 300)


Out[59]:
50

Highest Card Based on the highest card, assign points as follows: Ace = 10 points, K = 8 points, Q = 7 points, J = 6 points. 10 through 2, half of face value (10 = 5 points, 9 = 4.5 points, etc.)

Pairs For pairs, multiply the points by 2 (AA=20, KK=16, etc.), with a minimum of 5 points for any pair. 55 is given an extra point (i.e., 6).

Suited Add 2 points for suited cards.

Closeness Subtract 1 point for 1 gappers (AQ, J9) 2 points for 2 gappers (J8, AJ). 4 points for 3 gappers (J7, 73). 5 points for larger gappers, including A2 A3 A4 Add an extra point if connected or 1-gap and your highest card is lower than Q (since you then can make all higher straights)


In [83]:
import collections

Card = collections.namedtuple('Card', ['rank', 'suit'])
Rank = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]
Points = [1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5, 6, 7, 8, 10]
Suit = ['s', 'h', 'd', 'c']

def highest_card(x, y):
    if 'A' in (x.rank, y.rank): return 10
    if 'K' in (x.rank, y.rank): return 8
    if 'Q' in (x.rank, y.rank): return 7
    if 'J' in (x.rank, y.rank): return 6
    else: return max(x.rank, y.rank) / 2
    
def paired(x, y):
    if x.rank == y.rank:
        if 'A' in (x.rank, y.rank): return 10 * 2
        if 'K' in (x.rank, y.rank): return 8 * 2
        if 'Q' in (x.rank, y.rank): return 7 * 2
        if 'J' in (x.rank, y.rank): return 6 * 2
        else: 
            if x.rank >= 6: return x.rank
            if x.rank == 5: return 6
            else: return 5            
    return 0

def suited(x, y):
    if x.suit == y.suit: return 2
    return 0

def closeness(x, y):
    return 0 

def chen(x, y):
    return highest_card(x, y) + pairs(x, y) + suited(x, y) + closeness(x, y)

In [84]:
x = Card(rank = 'A', suit = 's')
y = Card(rank = 'J', suit = 's')


---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-84-8fb7d26dda19> in <module>()
----> 1 x = Card(rank = 'A', suit = 's')
      2 y = Card(rank = 'J', suit = 's')

TypeError: __new__() missing 2 required positional arguments: 'pts' and 'gap'

In [62]:
highest_card(x,y)


Out[62]:
10

In [63]:
pairs(x,y)


Out[63]:
0

In [64]:
suit(x,y)


Out[64]:
2

In [75]:
chen(x,y)


Out[75]:
12

In [77]:
Rank


Out[77]:
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 'J', 'Q', 'K', 'A']

In [82]:
abs(Rank[5] - Rank[4])


Out[82]:
1

In [ ]: