Ranking poker hands: Difference between revisions
Jump to navigation
Jump to search
Miraheze>Marshall No edit summary |
Miraheze>Marshall mNo edit summary |
||
Line 1: | Line 1: | ||
This article uses [[Dyalog APL]] to rank poker hands using the rules of [ | This article uses [[Dyalog APL]] to rank poker hands using the rules of [[wikipedia:Texas hold 'em|Texas hold 'em]] and other popular poker variants. The function <source lang=apl inline>handrank</source> below transforms a representation of a poker hand into a "rank" array so that the ordering of ranks under [[total array ordering]] is the same as the ordering of the initial poker hands. Poker hands can then by sorted or compared by calling <source lang=apl inline>handrank</source> on each one, then ordering with normal APL functions. | ||
== Dyalog '19 version == | == Dyalog '19 version == | ||
Line 155: | Line 155: | ||
== Examples == | == Examples == | ||
To test our function, we can try it on the sample hands given in Wikipedia's page on Texas hold 'em [ | To test our function, we can try it on the sample hands given in Wikipedia's page on Texas hold 'em [[wikipedia:Texas hold 'em#Hand_values|here]]. The ranks for each of these hands are shown, as well as a [[grade up]] to demonstrate that they are in ascending order. | ||
<source lang=apl> | <source lang=apl> | ||
hands ← ' '(≠⊆⊢)'A♣4♡7♢K♣2♠ K♣K♡7♢2♣5♠ K♣K♡7♢7♣5♠ K♣K♡K♢7♣5♠ 3♣4♡5♢6♣7♠ K♣Q♣9♣8♣2♣ K♣K♡K♢7♣7♠ K♣K♡K♢K♠5♠ 3♣4♣5♣6♣7♣ T♡J♡Q♡K♡A♡' | hands ← ' '(≠⊆⊢)'A♣4♡7♢K♣2♠ K♣K♡7♢2♣5♠ K♣K♡7♢7♣5♠ K♣K♡K♢7♣5♠ 3♣4♡5♢6♣7♠ K♣Q♣9♣8♣2♣ K♣K♡K♢7♣7♠ K♣K♡K♢K♠5♠ 3♣4♣5♣6♣7♣ T♡J♡Q♡K♡A♡' |