javascript - How can I find the highest poker hand from a 9 card hand between 4 players? -


i've tried through several sources online , deal 5 card , 7 card hands. also, i'm not looking code, i'll try on own (although perhaps if you're willing, i'm looking implement in either python or javascript). want explain me steps involved in finding such hand (using pseudocode).

basically, i'm asking is: how can find highest poker hand 9 card hand between 4 players?

should assign highest poker hand numbers in ranking , parsing through each player's hand , see if hand contains number? seems little tedious , i'm not sure that's right way it.

also, noticed other hand evaluators set optimization , count number of bits per card played confused me.

edit: here's game i'm working on:

it's game 6x6 grid in 4 players pick cards wherever player piece lands on, pick card. cards standard 52 card deck cards face , 36 randomly selected cards deck used.

eventually, toward end of game, player @ contain 9 cards in hands.

the way win game contain highest poker hand amongst 4 players around you.

so, essentially, if have royal flush , else has pair or straight, lose.

in game highest hand straight , rest have 3 of kind or 2 pair, person straight wins.

so, highest poker hand hand highest relative other player's hand. hand has highest ranking cards among 4 players.

poker hand regular hand may or may not highest in rank.

there 126 possible 5-cards combinations 9-cards hand. can iterate on them find highest. itertools.combinations(9_cards, 5) can generate of them.

to find highest, trivial implement define function gives hand score. use function key: max(all_5_cards_hands, key=hand_score)

you can use tuple represent score. leading hand ranking , followed card rankings.

an example:

straight_flush = 9 ... two_pair = 2 one_pair = 1 high_card = 0  hand_score('a7532')  # omit suits here # => (high_card, 14,7,5,3,2) hand_score('kk333') # => (full_house, 3, 13) hand_score('33444') # => (full_house, 4, 3) hand_score('akqj0') # => (straight, 14)  # tuples can compared: (high_card, 14,7,5,3,2) < (straight, 14) # => true 

Comments

Popular posts from this blog

Change php variable from jquery value using ajax (same page) -

Pull out data related to my apps from Android Play Store and iOS App Store -

How can I fetch data from a web server in an android application? -