![]() | Bovada is the only Internet casino endorsed by the Wizard. Here are my reasons why and my promise of support. |
64 bit word = one poker hand?
| November 22nd, 2011 at 1:00:51 PM permalink | |
| weaselman Member since: Jul 11, 2010 Threads: 17 Posts: 1924 | Why bother? Save 4 bytes per hand? How many hands do you need to have in memory at the same time? "When two people always agree one of them is unnecessary" |
| November 22nd, 2011 at 4:00:40 PM permalink | |
| CrystalMath Member since: May 10, 2011 Threads: 3 Posts: 476 |
These concepts are gold; they are invaluable to making a poker analyzer. The Wizard has some of the same info at the bottom of this page, but his requires numbers sorted low to high, and is not quite as straight forward: Video Poker Programming Tips I heart Crystal Math. |
| November 24th, 2011 at 4:20:23 AM permalink | |
| JB Administrator Member since: Oct 14, 2009 Threads: 309 Posts: 906 |
It depends on the application. For example, if you're writing something in Java then this would be the way to go since Java's memory constraints are restrictive. If you're creating a binary data file then you definitely want to go this route to minimize the disk space used for it. Another reason is to standardize the sequence of the cards (that is, to store combinations and not permutations). It would obviously be quicker to use a 64-bit number and just bit-shift the card indexes if memory is not an issue but speed is, but even if you do that you'll still have to sort the card indexes. |
| November 24th, 2011 at 5:38:21 AM permalink | |
| weaselman Member since: Jul 11, 2010 Threads: 17 Posts: 1924 |
Not sure what you mean by this. Java long is 8 bytes just like in (64 bit) C.
Nah... Gzip will pack it better than you ever would anyway.
I don't understand what this means. Sort the indexes? Why? "When two people always agree one of them is unnecessary" |
| November 24th, 2011 at 6:02:12 AM permalink | |
| JB Administrator Member since: Oct 14, 2009 Threads: 309 Posts: 906 |
Yes but the default amount of memory you can use for arrays is pretty limited, when designing an applet for the web anyway.
If adding another layer of complexity and slowing things down is worth it, sure.
For a 7-card hand, there are 7! = 5040 ways to arrange the card indexes. You don't want to store each unique hand 5040 times in an array with 674274182400 subscripts (consuming about 4.9 terabytes); it would be better to sort the card indexes and store each hand once in an array with 133784560 subscripts. Even so, that's about 1GB of memory if you use 64-bit integers, and of course only half of that if you use 32-bit integers. |
| November 24th, 2011 at 6:36:35 AM permalink | |
| weaselman Member since: Jul 11, 2010 Threads: 17 Posts: 1924 |
How much is it? I have not done applets for quite a while, don't remember anymore... Who uses defaults nowadays anyway?
Piping data through gzip is hardly "complexity". Especially, was compared.to your mapping algorithm :-) As for speed, reading and writing gzipped files is generally faster, than unpacked ones. Even if there is no significant reduction in size, it does not take any longer because io is done in parallel with gzip CPU activity.
Ah, yeah, that makes sense. Though, I am still not sure what kind of application requires storing this many hands. If you are doing a simulator, and just want to log every hand, you'd have to store as many hands as you play anyway, regardless of how they are represented. "When two people always agree one of them is unnecessary" |
| November 24th, 2011 at 6:57:08 AM permalink | |
| JB Administrator Member since: Oct 14, 2009 Threads: 309 Posts: 906 |
I don't know what the specific limit is, but I ran into problems trying to create an applet that generates video poker strategies. I would assume that those who don't specifically tinker with Java's memory settings are the ones who use defaults.
We may be arguing two different things here. I see my method to map hands as the most efficient and simple method possible. Using compression only comes into play if you're saving or loading the array to/from a file (or memory stream).
For a calculator it would be useful. For example, if you know two hole cards, loop through the other 5 cards, calculate the combination, and look up the hand type in the array; this is much faster than calling a separate function to determine the hand rank due to the overhead of calling a function 2,118,760 times. |
| November 24th, 2011 at 7:13:15 AM permalink | |
| s2dbaker Member since: Jun 10, 2010 Threads: 34 Posts: 1215 | I do everything in MS-SQL. It's so easy to program and store results. I'm perfectly happy with resolving only 5000 rounds of poker per second. Since there are only 7462 possible 5 card poker outcomes, it's easy to store the results in a table. |
![]() | Bovada is the only Internet casino endorsed by the Wizard. Here are my reasons why and my promise of support. |
