fix twostartcards to handle 22 and unknowns properly
This commit is contained in:
parent
1a4de58e33
commit
012b5bc72c
|
@ -20,23 +20,36 @@
|
|||
|
||||
def twoStartCards(value1, suit1, value2, suit2):
|
||||
""" Function to convert 2 value,suit pairs into a Holdem style starting hand e.g. AQo
|
||||
Hand is stored as an int 13 * x + y where (x+2) represents rank of 1st card and
|
||||
Incoming values should be ints 2-14 (2,3,...K,A), suits are 'd'/'h'/'c'/'s'
|
||||
Hand is stored as an int 13 * x + y + 1 where (x+2) represents rank of 1st card and
|
||||
(y+2) represents rank of second card (2=2 .. 14=Ace)
|
||||
If x > y then pair is suited, if x < y then unsuited"""
|
||||
if value1 < 2 or value2 < 2:
|
||||
If x > y then pair is suited, if x < y then unsuited
|
||||
Examples:
|
||||
0 Unknown / Illegal cards
|
||||
1 22
|
||||
2 32o
|
||||
3 42o
|
||||
...
|
||||
14 32s
|
||||
15 33
|
||||
16 42o
|
||||
...
|
||||
170 AA
|
||||
"""
|
||||
if value1 is None or value1 < 2 or value1 > 14 or value2 is None or value2 < 2 or value2 > 14:
|
||||
ret = 0
|
||||
if value1 == value2: # pairs
|
||||
ret = (13 * (value2-2) + (value2-2) )
|
||||
elif value1 == value2: # pairs
|
||||
ret = (13 * (value2-2) + (value2-2) ) + 1
|
||||
elif suit1 == suit2:
|
||||
if value1 > value2:
|
||||
ret = 13 * (value1-2) + (value2-2)
|
||||
ret = 13 * (value1-2) + (value2-2) + 1
|
||||
else:
|
||||
ret = 13 * (value2-2) + (value1-2)
|
||||
ret = 13 * (value2-2) + (value1-2) + 1
|
||||
else:
|
||||
if value1 > value2:
|
||||
ret = 13 * (value2-2) + (value1-2)
|
||||
ret = 13 * (value2-2) + (value1-2) + 1
|
||||
else:
|
||||
ret = 13 * (value1-2) + (value2-2)
|
||||
ret = 13 * (value1-2) + (value2-2) + 1
|
||||
|
||||
# print "twoStartCards(", value1, suit1, value2, suit2, ")=", ret
|
||||
return ret
|
||||
|
@ -47,8 +60,8 @@ def twoStartCardString(card):
|
|||
ret = 'xx'
|
||||
if card > 0:
|
||||
s = ('2', '3', '4', '5', '6', '7', '8', '9', 'T', 'J', 'Q', 'K', 'A')
|
||||
x = card / 13
|
||||
y = card - 13 * x
|
||||
x = (card-1) / 13
|
||||
y = (card-1) - 13 * x
|
||||
if x == y: ret = s[x] + s[y]
|
||||
elif x > y: ret = s[x] + s[y] + 's'
|
||||
else: ret = s[y] + s[x] + 'o'
|
||||
|
|
|
@ -516,8 +516,8 @@ class GuiPlayerStats (threading.Thread):
|
|||
if holecards: # re-use level variables for hole card query
|
||||
query = query.replace("<hgameTypeId>", "hp.startcards")
|
||||
query = query.replace("<orderbyhgameTypeId>"
|
||||
, ",case when floor(hp.startcards/13) >= mod(hp.startcards,13) then hp.startcards + 0.1 "
|
||||
+ " else 13*mod(hp.startcards,13) + floor(hp.startcards/13) "
|
||||
, ",case when floor((hp.startcards-1)/13) >= mod((hp.startcards-1),13) then hp.startcards + 0.1 "
|
||||
+ " else 13*mod((hp.startcards-1),13) + floor((hp.startcards-1)/13) + 1 "
|
||||
+ " end desc ")
|
||||
else:
|
||||
query = query.replace("<orderbyhgameTypeId>", "")
|
||||
|
|
Loading…
Reference in New Issue
Block a user