Module onejoker::cards::hashes

source ·
Expand description

wiki | Various hash functions for cards

The common FNV hashes are often used for implementing hash tables and doing quick checksumming for tests. They are not collision-free, but are fast and simple.

Positional hashes treat cards (or ranks) as digits of a base-n number, They are therefore order-dependent and limited in size, but inherently collision-free and useful for ranking hands.

Bitfield hashes represent each card as a bit in a 64-bit integer. This is inherently order-independent and collision-free, and very fast, but can’t handle duplicate cards and produces huge numbers.

Prime hashes based on the product of prime numbers are inherently collision-free, order-independent, handle duplicates, and produce smaller numbers, but can only handle very small sets.

The “mp” functions create minimal perfect hashes for particular games and are very specific to number of cards and type of deck.

Constants§

Functions§