![]() | 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 21st, 2011 at 3:06:35 PM permalink | |
| RaspberryCheeseBlintz Member since: Oct 22, 2011 Threads: 5 Posts: 30 | I was wondering if, since you can squeeze a 7 card poker hand into one 64 bit word (7*8 = 56, plus some extra info in the high byte) there would be any speed advantages for simulations? |
| November 21st, 2011 at 3:20:08 PM permalink | |
| weaselman Member since: Jul 11, 2010 Threads: 17 Posts: 1924 | You actually only need 42 bits (6*7=42). But I am not sure I understand where you get a connection with speed here ... And what do you compare with what when you are talking about "advantages". "When two people always agree one of them is unnecessary" |
| November 21st, 2011 at 3:22:55 PM permalink | |
| Paigowdan Member since: Apr 28, 2010 Threads: 54 Posts: 2130 | Yes, bit mapping as a data structure affords great speed in processing, but may make for messy programming. Gambling doesn't build character, it reveals..no character. But a lot of characters. |
| November 21st, 2011 at 3:26:46 PM permalink | |
| weaselman Member since: Jul 11, 2010 Threads: 17 Posts: 1924 |
The only thing that makes for messy programming is messy programmers. Bit mapping isn't really a data structure. But if you design a data structure that uses a bit map, that is likely to make your program work slower (or, perhaps, as fast), not faster, but require less memory (unless you are trying to map like every poker hand to a bit or something like that - that would be both slow, and bloated). "When two people always agree one of them is unnecessary" |
| November 21st, 2011 at 3:43:58 PM permalink | |
| teliot Member since: Oct 19, 2009 Threads: 5 Posts: 75 | This site has helped me a lot along the way: Poker hand evaluator roundup "I think we are in rats' alley, where the dead men lost their bones." - T.S. Eliot |
| November 21st, 2011 at 3:44:28 PM permalink | |
| Paigowdan Member since: Apr 28, 2010 Threads: 54 Posts: 2130 | Very true. But if you give programmers less to hang themselves with, there are generally less hangings. This is because there are programmers, and there are PROGRAMMERS. I was an old school ALGOL programmer on Burroughs (Unisys) equipment back in the day, and by using DEFINEs properly, bit mapping can indeed be well-organized. Gambling doesn't build character, it reveals..no character. But a lot of characters. |
| November 21st, 2011 at 5:55:02 PM permalink | |
| RaspberryCheeseBlintz Member since: Oct 22, 2011 Threads: 5 Posts: 30 |
Thanks for the responses, and in particular the above site. I'm afraid I saw too much of myself in the paragraph on "naive simulators" and so will have to rethink a few things. My original plan was to code in pascal; will using the provided code be possible in that language, or will I have to learn C++ (and get a compiler for that too)? |
| November 21st, 2011 at 6:38:21 PM permalink | |
| MarkAbe Member since: Oct 23, 2010 Threads: 1 Posts: 50 | Raspberry, that site has a lot of good code. If I remember Pascal at all (it's been a long time) they will not work in Pascal. For most uses C++/C#/Java are easy to adapt between, I'd go with one of them. C++ (from the Gnu C++ compiler) and Java are free. C# you will probably have to pay Microsoft for. |
| November 22nd, 2011 at 12:35:32 PM permalink | |
| JB Administrator Member since: Oct 14, 2009 Threads: 309 Posts: 906 | You can fit it into a 32-bit integer. There are combin(52,7) = 133,784,560 possible hands, which only requires 27 bits. To start, I recommend using pre-populated arrays for the combin(n,k) function with a value of 0 for evaluations that would normally result in an error condition, such as combin(2, 3). Here would be the code for a 52-card deck: int[] Choose2 = { 0, 0, 1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105, 120, 136, 153, 171, 190, 210, 231, 253, 276, 300, Then if you number each card from 0 to 51, and each hand from 0 to 133784559, you can convert 7 card indexes to a hand index as follows: Choose7[card7] + Choose6[card6] + Choose5[card5] + Choose4[card4] + Choose3[card3] + Choose2[card2] + card1 ...where card7 is the highest-numbered card index and card1 is the lowest-numbered card index (it is critical that the card indexes are sorted from highest to lowest). Then, to convert a hand index (0 ... 133784559) to card indexes, use the following logic: int card1 = hand_index, card2, card3, card4, card5, card6, card7; ...where hand_index is the hand index from 0 to 133784559. The result will be 7 card indexes in sorted order (card1 being the lowest-numbered card index, and card7 the highest-numbered one), just as was required for the function to compute the hand index. Hope that helps! |
| November 22nd, 2011 at 12:41:06 PM permalink | |
| RaspberryCheeseBlintz Member since: Oct 22, 2011 Threads: 5 Posts: 30 | Wow, my stack overfloweth...thanks, that sure looks really efficient. |
![]() | Bovada is the only Internet casino endorsed by the Wizard. Here are my reasons why and my promise of support. |
