TransWikia.com

bounded Cantor pairing?

Mathematics Asked by Some guy on August 21, 2020

I know this is not the coding stack exchange but the first three paragraphs just pertain to the background (I hope it is not too jargon heavy). My question itself is more mathematical. Also I don’t have that much knowledge regarding mathematics.

I am a hobby programmer doing some things with poker abstraction. I currently have cards encoded as unique integers.

Anyway, For the purpose of constructing a unique id for each game-state (Hand, Flop etc…) I would like to exploit a recursive pairing function which expands with the previous result and each new card that comes into play, and suite relations. I am aware of Cantor’s pairing function and similar methods. But these will quickly overflow (i.e. the numbers become too large for my script to handle). But I am guessing it should be possible to construct a sort of ‘bounded’ pairing function in order to keep the expansion rate somewhat in check?

All be possible states in poker (barring bet-sequences) amount to 2,428,287,420. So it should be possible to create a function that maps each state to a max value of 2,428,287,420. For reference, the amount I can hold in a 3 byte integer (my goal) is 4,294,967,296.

I wish to instate a pairing function where one axis is ‘bounded’. For example, in the image below:

cantor pairing image

if I knew A priori that for all usages of the function y < 3 I would never have to map (0,3) to 9. Instead I could map (4,0) to 9 and thereby compress the output of my function. sadly I found little reference how to do this (or if it is possible with a relatively simple formula).

could you guys nudge me in the right direction?

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP