a 1˜eV ã@sdZGdd„dƒZdS)a‚ Static class that handles cards. We represent cards as 32-bit integers, so there is no object instantiation - they are just ints. Most of the bits are used, and have a specific meaning. See below: Card: bitrank suit rank prime +--------+--------+--------+--------+ |xxxbbbbb|bbbbbbbb|cdhsrrrr|xxpppppp| +--------+--------+--------+--------+ 1) p = prime number of rank (deuce=2,trey=3,four=5,...,ace=41) 2) r = rank of card (deuce=0,trey=1,four=2,five=3,...,ace=12) 3) cdhs = suit of card (bit turned on based on suit of card) 4) b = bit turned on depending on rank of card 5) x = unused This representation will allow us to do very important things like: - Make a unique prime prodcut for each hand - Detect flushes - Detect straights and is also quite performant. c@s~eZdZdZedƒZgd¢Zeee eƒeƒƒZ dddddœZ d Z d d d d dœZ ddgZedd„ƒZedd„ƒZedd„ƒZdS)ÚCardÚ 23456789TJQKAé ) ééééé réééééé%é)éréé)ÚsÚhÚdÚcÚ xshxdxxxcuâ™ uâ¤u♦u♣)rrrrc CsZ|d}|d}tj|}tj|}tj|}d|>d>}|d>}|d>}||B|B|BS)zœ Converts Card string to binary integer representation of card, inspired by: http://www.suffecool.net/poker/evaluator.html éréé r)rÚCHAR_RANK_TO_INT_RANKÚCHAR_SUIT_TO_INT_SUITÚPRIMES) ÚstringÚ rank_charÚ suit_charÚrank_intÚsuit_intÚ rank_primeÚbitrankÚsuitÚrank©r'ú;/Users/seanglover/Development/deuces-rs/deuces3/card_mvp.pyÚnew2s    zCard.newcCs.d}tjD]}|d|>@r |tj|9}q |S)aÞ Returns the prime product using the bitrank (b) bits of the hand. Each 1 in the sequence is converted to the correct prime and multiplied in. Params: rankbits = a single 32-bit (only 13-bits set) integer representing the ranks of 5 _different_ ranked cards (5 of 13 bits are set) Primarily used for evaulating flushes and straights, two occasions where we know the ranks are *ALL* different. Assumes that the input is in form (set bits): rankbits +--------+--------+ |xxxbbbbb|bbbbbbbb| +--------+--------+ r)rÚ INT_RANKSr)ÚrankbitsÚproductÚir'r'r(Úprime_product_from_rankbitsFs   z Card.prime_product_from_rankbitscCsd}|D]}||d@9}q|S)z; Expects a list of cards in integer form. réÿr')Ú card_intsr,rr'r'r(Úprime_product_from_hand`szCard.prime_product_from_handN)Ú__name__Ú __module__Ú __qualname__Ú STR_RANKSÚranger*rÚdictÚzipÚlistrrÚINT_SUIT_TO_CHAR_SUITÚ PRETTY_SUITSÚ PRETTY_REDSÚ staticmethodr)r.r1r'r'r'r(rs,üü  rN)Ú__doc__rr'r'r'r(Ús