This code uses 2 bits to represent suits, 6 bits to represent each card (2 suit bits + 4 rank bits), and can represent an arbitrary hand (set of cards) as a 64-bit value (64 = 2^6). It has different card values for low and high aces (each are used in some games), and low and high jokers (each used in some games). This lets you represent hands from essentially any card game really compactly and perform operations on them efficiently. Now someone just needs to write some code that actually deals and plays games
That looks like it, although I believe this is a command line version. The original had a simple gui whose grid was used by aspiring poker pros to study and compare hand ranges, and that has since been adopted by many other poker training tools. It builds a lookup table for speed. The core evaluator can be found at [pokerstove eval] (https://github.com/andrewprock/pokerstove/tree/master/src/lib/pokerstove/peval).
If I only had the time, a pure Julia version + Escher UIâŚ
Note that this Hand data structure assumes that there is only one of each card, which doesnât work for games like pinochle that have 2 (or more) of each card (by combining multiple standard decks or by using custom decks). And the Hand constructor doesnât check for this possibility (it ignores cards that appear more than once).
(Also, pinochle uses a nonstandard card ranking: A 10 K Q J 9, and there are no cards below a 9. So maybe it is too weird to support. )
Non standard card rankings are pretty common for german card games. I also know at least two games with multiple sets of cards.
This also applies to the suits: In germany, the usual order is Clubs, Spades, Hearts, Diamonds.
A card type could also use a value field for scoring.
I would think that the mapping from cards to values would be a property of a game, i.e a separate dictionary-like object, not a property of individual cards.
I intentionally did not order the suits, although, of course, I had to pick an encoding. The encoding I chose is based on bridge ordering of suits â since I play bridge, and itâs a game where suit ordering is significant. In poker, suit ordering mostly doesnât matter. It would certainly be possible to have a multiset hand type, but I think thatâs beyond the scope of an initial cut of such a package.
In Spain, they also have many 2 deck games, and the suits are different, cups, swords, clubs, and coins (red, silver, green, gold) Also, many games are played with 40 card decks, which have only: Ace, 2 - 7, and Knave (Sota), Knight (Caballo), King (Rei) for the face cards.
Also, pinochle uses a nonstandard card ranking: A 10 K Q J 9, and there are no cards below a 9. So maybe it is too weird to support.
My favorite card game Jass (from Switzerland) has no cards below 6, and the rank order is different, but only for the trump suit. In the trump suit, the order is (high-low) J 9 A K Q 10 8⌠but in all others itâs A-6.
Hmmm⌠the names are so similar that I wonder if Jass is related to the Dutch game of Klaverjassen
Jass, first mentioned in Switzerland in 1796,[1] was originally the name of the highest trump, the Jack, in a family of related games originally spread from the Netherlands during the Late Middle Ages.
Well, that implies they are! Funny how neither page mentions either though - you can dive down the rabbit hole of wikipedia cardgame pages and have no clue of their connection:
I hope a history PhD is working on a card games family network graph somewhere to fix this