Hi Elmer, On Tue, Aug 10, 2010 at 02:58:21PM -0500, Elmer Fittery wrote: > More reading brought up a question about the random generation of the > cards. > > >From looking at the poker-eval source code I noted that: > > DECK_MONTECARLO_N_CARDS_D and DECK_MONTECARLO_PERMUTATIONS_D do not > produce unique random decks. > > To force a new random deck every time these #defines are used, I > modified them to do a srand( value ) every time they are called.
srand() allow to initialize a new (pseudo-)random number sequence. Why
would you do that for every DECK_MONTECARLO_N_CARDS_D call ?
If the default random seed is not good enough, you could call srand()
once before using libpoker_eval...
>
> To produce the argument for srand, I used read /def/urandom.
>
> The following is my modified version of #define
> DECK_MONTECARLO_N_CARDS_D found in includes/enumerate.h
>
> #define DECK_MONTECARLO_N_CARDS_D(deck, cards_var, dead_cards, \
> num_cards, num_iter, action) \
> \
> int value = 0; \
> read((open("/dev/urandom", O_RDONLY)), &value, 4); \
> srand( value); \
Maybe you want move the 3 line above into the "do {} while(0)"
statement.
Otherwise you will break evaluations like:
"if DECK_MONTECARLO_N_CARDS_D(...) { }"
> \
> do { \
> int _i, _j, _c; \
> \
> for (_i=0; _i<num_iter; _i++) { \
> deck##_CardMask _used; \
> _used = dead_cards; \
> deck##_CardMask_RESET(cards_var); \
> for (_j=0; _j<num_cards; _j++) { \
> do { \
> _c = RANDOM() % deck##_N_CARDS; \
> } while (deck##_CardMask_CARD_IS_SET(_used, _c)); \
> deck##_CardMask_SET(cards_var, _c); \
> deck##_CardMask_SET(_used, _c); \
> } \
> { action }; \
> }; \
> } while (0)
>
> To modify the #define DECK_MONTECARLO_PERMUTATIONS_D the same approach
> was taken.
>
> NOTE: By doing this, the tests provided in the poker-eval tree will
> fail if the compiled code uses these #define .....
>
> That is because the results will change every time you test. The change
> will be small, but it will not match perfectly.
>
> As an example:
>
> el...@elmer-desktop:~/poker-eval/examples$ ./pokenum -mc 100000 -h Ac 7c
> - 5s 4s - Ks Kd
> Holdem Hi: 100000 sampled boards
> cards win %win lose %lose tie %tie EV
> Ac 7c 27250 27.25 72422 72.42 328 0.33 0.274
> 5s 4s 19982 19.98 79690 79.69 328 0.33 0.201
> Ks Kd 52440 52.44 47232 47.23 328 0.33 0.525
> el...@elmer-desktop:~/poker-eval/examples$ ./pokenum -mc 100000 -h Ac 7c
> - 5s 4s - Ks Kd
> Holdem Hi: 100000 sampled boards
> cards win %win lose %lose tie %tie EV
> Ac 7c 27354 27.35 72331 72.33 315 0.32 0.275
> 5s 4s 20037 20.04 79648 79.65 315 0.32 0.201
> Ks Kd 52294 52.29 47391 47.39 315 0.32 0.524
>
> Note that running the same thing produces different results.
>
> This means that the shuffling of the deck produces different results
> every time the #define DECK_MONTECARLO_PERMUTATIONS_D is used.
The non-modified pokenum provide the same results because the same seed
(default) is used to initialize the random number sequence. What's wrong
with that ?
Regards,
Simon
signature.asc
Description: Digital signature
_______________________________________________ Pokersource-users mailing list [email protected] https://mail.gna.org/listinfo/pokersource-users
