BBO Discussion Forums: BBO random generator - BBO Discussion Forums

Jump to content

  • 3 Pages +
  • 1
  • 2
  • 3
  • You cannot start a new topic
  • You cannot reply to this topic

BBO random generator

#1 User is offline   bluecalm 

  • PipPipPipPipPipPipPip
  • Group: Advanced Members
  • Posts: 2,555
  • Joined: 2007-January-22

Posted 2012-October-05, 07:44

Intuively I feel that hands on BBO are flatter than hands I play live (also generated by computer but i don't know which program).
Is there any resource about BBO random generator ? I am just curios, I am aware that probably my intuition is just wrong about it but I would like to see what kind of generator BBO is using and if it is good.
0

#2 User is offline   cloa513 

  • PipPipPipPipPipPip
  • Group: Advanced Members
  • Posts: 1,528
  • Joined: 2008-December-02

Posted 2012-October-07, 01:38

View Postbluecalm, on 2012-October-05, 07:44, said:

Intuively I feel that hands on BBO are flatter than hands I play live (also generated by computer but i don't know which program).
Is there any resource about BBO random generator ? I am just curios, I am aware that probably my intuition is just wrong about it but I would like to see what kind of generator BBO is using and if it is good.

This probably a better question for the BBO Support Forum- there you might get an answer.
0

#3 User is offline   Antrax 

  • PipPipPipPipPipPip
  • Group: Advanced Members
  • Posts: 2,458
  • Joined: 2011-March-15
  • Gender:Male

Posted 2012-October-07, 02:16

What you're describing sounds reasonable, as hand-dealing is "less random" than a well-implemented PRNG, and it's more likely BBO uses correct practices than dealing programs (just because BBO is more high profile).
0

#4 User is offline   dwar0123 

  • PipPipPipPipPip
  • Group: Full Members
  • Posts: 770
  • Joined: 2011-September-23
  • Gender:Male
  • Location:Bellevue, WA

Posted 2012-October-09, 13:59

View PostAntrax, on 2012-October-07, 02:16, said:

What you're describing sounds reasonable, as hand-dealing is "less random" than a well-implemented PRNG, and it's more likely BBO uses correct practices than dealing programs (just because BBO is more high profile).

My understanding was that hand-dealing actually results in flatter hands. Regardless he was comparing BBO dealt hands to other computer dealt hands and in both cases while computer pseudo random number generation is not truly random(hence the pseudo) the difference is utterly indistinguishable to humans*. Pseudo random number generation has been a solved problem for over a decade and it is very unlikely either bbo or another computer dealing program is screwing it up. Possible, but here I would wager pretty heavily on your intuition being wrong.


*without taking a lot of actual unbiased samples and pouring over them with some math.
0

#5 User is offline   Antrax 

  • PipPipPipPipPipPip
  • Group: Advanced Members
  • Posts: 2,458
  • Joined: 2011-March-15
  • Gender:Male

Posted 2012-October-09, 22:10

Formally, the difference between pseudo and truly random is such that a computationally bounded adversary cannot detect it. In simple terms, it means that assuming no implementation flaws, a team of NSA experts using all the computing resources in the world won't be able to distinguish between a PRNG's output and God himself giving them random numbers, in time to make it for the heat death of the universe.

Intuitively, hand-dealing depends on the algorithm used, but from my experience, people usually just do a couple of riffle shuffles. Those tend to leave clumps intact, especially as the cards age. That would result in hands with wilder shape and an uneven distribution of HCP, as people tend to do things like clear suits and cash out, which cause HCPs and suits to bunch together at the end of play.

But there's an awful lot of speculation here from my part, so if anyone has contrary notions, feel free to correct me.
0

#6 User is offline   barmar 

  • PipPipPipPipPipPipPipPipPipPipPipPip
  • Group: Admin
  • Posts: 21,412
  • Joined: 2004-August-21
  • Gender:Male

Posted 2012-October-10, 09:12

The BBO dealer is very simple:

    for ( w=1; w<4; w++ )
    {
      for ( c=0; c<13; c++ )
      {
        do
        {
          s=rand()%4;
          c1=rand()%13;
        } while ( PLAYARRAY[s][c1]!=0 );
        PLAYARRAY[s][c1]=w;
      }
    }

The Linux rand() function isn't random enough for cryptographic use, but it seems to be good enough for dealing bridge hands. Uday told me that we get the expected statistics of hand distributions.

#7 User is offline   TylerE 

  • PipPipPipPipPipPipPip
  • Group: Advanced Members
  • Posts: 2,760
  • Joined: 2006-January-30

Posted 2012-October-10, 09:22

Wow, that seems like a bit of an archaic way to do it. Why not use a Knuth shuffle, which will always complete in exactly 52 steps?
0

#8 User is offline   Antrax 

  • PipPipPipPipPipPip
  • Group: Advanced Members
  • Posts: 2,458
  • Joined: 2011-March-15
  • Gender:Male

Posted 2012-October-10, 09:27

That's a bit weird. rand() % is a well-known bad practice. It's true you're not running a bank, but why not use one of the many existing good implementations?
0

#9 User is offline   dwar0123 

  • PipPipPipPipPip
  • Group: Full Members
  • Posts: 770
  • Joined: 2011-September-23
  • Gender:Male
  • Location:Bellevue, WA

Posted 2012-October-10, 10:52

Have to admit, that is surprisingly inefficient.

But beyond that, if there is any tilt to rand()% implementation, the order and method of dealing cards is greatly magnifying it.

Player 1 is getting the first 13 cards dealt and as such any tilt means that he is vastly more likely to get the more common rand results. Player 4 is in the exact opposite position.

If you merely reversed the order of the w and c for loops, you would nullify the vast majority of this bias. This would effectively be equivalent to dealing around the table rather then taking 13 cards off the top and giving them to player 1.

Of course, if rand()% is effectively random and unbiased, then everything is fine. But a lot of literature says that this can be very problematic.
0

#10 User is offline   barmar 

  • PipPipPipPipPipPipPipPipPipPipPipPip
  • Group: Admin
  • Posts: 21,412
  • Joined: 2004-August-21
  • Gender:Male

Posted 2012-October-10, 12:41

The documentation I've read says that rand() is uniformly distributed, and in current implementations the low-order bits are as random as the high order ones. RAND_MAX is the same as INT_MAX, and they're both 2^32-1, so rand()%(2^N) should be unbiased. rand()%13 will have a tiny bias because INT_MAX+1 is not a multiple of 13; I believe it's 0.0000003% in favor of 2-10 versus J-A. At our current rate and allowing for generous growth, that's 1-2 hands per decade.

I think that's negligible. So while there may be better ways to deal, I don't think we gain much by "fixing" it.

#11 User is offline   nigel_k 

  • PipPipPipPipPipPip
  • Group: Advanced Members
  • Posts: 2,207
  • Joined: 2009-April-26
  • Gender:Male
  • Location:Wellington, NZ

Posted 2012-October-10, 12:53

Looks fine to me. You guys nitpick too much. It isn't efficient, but that's irrelevant when the time cost of operations and number of hands to deal is so small.
1

#12 User is offline   dwar0123 

  • PipPipPipPipPip
  • Group: Full Members
  • Posts: 770
  • Joined: 2011-September-23
  • Gender:Male
  • Location:Bellevue, WA

Posted 2012-October-10, 16:32

Fair enough, my assumptions were that any modern implementation of rand() would be so close to random as to be indiscernible to a semi-serious observer. Seeing the details sadly focused me on the flaws, no matter how indiscernible they might still have been.

I wonder how much dealing the first 13 cards to player 1 increases the 0.0000003% for that player.
0

#13 User is offline   barmar 

  • PipPipPipPipPipPipPipPipPipPipPipPip
  • Group: Admin
  • Posts: 21,412
  • Joined: 2004-August-21
  • Gender:Male

Posted 2012-October-10, 17:50

View Postdwar0123, on 2012-October-10, 16:32, said:

Fair enough, my assumptions were that any modern implementation of rand() would be so close to random as to be indiscernible to a semi-serious observer. Seeing the details sadly focused me on the flaws, no matter how indiscernible they might still have been.

I wonder how much dealing the first 13 cards to player 1 increases the 0.0000003% for that player.

If the dealer were perfectly random, each card dealt to a player would have a 9/13 chance of being 2-10. Because of this minor flaw, that chance is increased to 9.000000027/13 for the first card dealt to player 1. As each card is dealt, the probabilities change a bit because of the cards that are no longer available to be dealt, but I believe the difference from perfection will be of a similar magnitude.

So player N is slightly more likely to have low cards than player N+1. But this extra likelihood is on the order of 1 in 10 million. While this is better than playing the lottery, it still doesn't seem like something you can take advantage of. If you play 1,000 hands a day, and play these odds, you'll get a benefit once every 10,000 days, which is 27 years. Most of the probability factors that we deal with in bridge are on the order of a percent or more, and this additional factor is totally negligible compared to them. If you had a true 2-way guess for an honor, you might as well finesse away from a lower-numbered hand; but I'll bet if you really thought about it you could find some information that helps you more than this tiny fraction -- it's negligible compared to a single vacant space.

BTW, if you play best-hand robot tourneys, hand 1 is the human's hand, and his hand is swapped with the best hand after the dealing. So there's no way of knowing where hand 1 ended up (but I suppose hand 4 is infinitessimally more likely to be the best hand, so a 1<->4 swap is ever so slightly more likely).

#14 User is offline   cloa513 

  • PipPipPipPipPipPip
  • Group: Advanced Members
  • Posts: 1,528
  • Joined: 2008-December-02

Posted 2012-October-10, 22:03

View Postnigel_k, on 2012-October-10, 12:53, said:

Looks fine to me. You guys nitpick too much. It isn't efficient, but that's irrelevant when the time cost of operations and number of hands to deal is so small.

To answer to that you need to estimate how big BBO is now? I bet GIB running simulations during bidding is the heaviest part since its supposed to simulate the complete bidding sequence and play sequence.
0

#15 User is offline   nathan2008 

  • PipPipPipPip
  • Group: Full Members
  • Posts: 173
  • Joined: 2012-March-21

Posted 2012-October-11, 09:06

According to what i've learned in the school, I totally agree with Barmar. But my teacher tells me that it is 2^31-1, not 2^32-1 lol. (Because 2^31-1 is a prime number while 2^32-1 isn't :( ) That is how comupter makes random number. I feel confident to programmers.
0

#16 User is offline   billw55 

  • enigmatic
  • PipPipPipPipPipPipPip
  • Group: Advanced Members
  • Posts: 4,757
  • Joined: 2009-July-31
  • Gender:Male

Posted 2012-October-11, 13:49

If you wanted, you could get seeds from true random generators like hotbits. The hands themselves would not be distinguishable, but it might make some people feel better about it.
Life is long and beautiful, if bad things happen, good things will follow.
-gwnn
0

#17 User is offline   dwar0123 

  • PipPipPipPipPip
  • Group: Full Members
  • Posts: 770
  • Joined: 2011-September-23
  • Gender:Male
  • Location:Bellevue, WA

Posted 2012-October-11, 14:27

View Postbillw55, on 2012-October-11, 13:49, said:

If you wanted, you could get seeds from true random generators like hotbits. The hands themselves would not be distinguishable, but it might make some people feel better about it.

That wouldn't actually solve the (non)problem. The problem is that max number that rand() can come up with isn't divisible by 13, thus when you use the % operator(mod), there are more cases for the lower numbers than the higher numbers.

As an example, we can use a really tiny max number to make it really explicit.

If the max number rand() can come up with is 2^4-1(15). Thus rand() will generate an integer between 0 and 15 inclusive.

0 % 13 = 0
1 % 13 = 1
2 % 13 = 2
3 % 13 = 3
4 % 13 = 4
...
13 % 13 = 0
14 % 13 = 1
15 % 13 = 2

If we assign 0 to represent dealing a 2 of a suit and 12 to an Ace of a suit than the first card dealt is twice as likely to be a 2(0) than an A(12). What seed we use has no impact on this.

However using a really gigantic MAX_RAND diminishes the biases to the level Barmar stated.
0

#18 User is offline   mycroft 

  • Secretary Bird
  • PipPipPipPipPipPipPipPip
  • Group: Advanced Members
  • Posts: 7,107
  • Joined: 2003-July-12
  • Gender:Male
  • Location:Calgary, D18; Chapala, D16

Posted 2012-October-11, 17:56

I would suggest that if their idle thread (or another process) busy-waited calling rand() that I would feel better.

Unix/Linux has /dev/urandom, which is non-pseudo RNG, it generates bits out of an entropy pool it tries to keep up by using environmental randomness. For BBO, I wouldn't worry about rand(); for people making hand records for Bermuda Bowl and the like, avoiding a PRNG is probably worth it - I postulated years ago that someone with $1M to build special hardware and access to the vugraph could likely crack a 36-deal set made from a single seed in time to know the last few boards. Computing power hasn't got *more expensive*.

Take log2(hands^36) bits of true randomness (or log2(hands)*36, if randomness is cheaper than huge modulo division (which it probably is)) and build 36 unconnected, true random hands for each set, and you've OTPed it. But, as I said, that's almost certainly overkill for BBO.
When I go to sea, don't fear for me, Fear For The Storm -- Birdie and the Swansong (tSCoSI)
0

#19 User is offline   barmar 

  • PipPipPipPipPipPipPipPipPipPipPipPip
  • Group: Admin
  • Posts: 21,412
  • Joined: 2004-August-21
  • Gender:Male

Posted 2012-October-11, 18:27

View Postcloa513, on 2012-October-10, 22:03, said:

To answer to that you need to estimate how big BBO is now? I bet GIB running simulations during bidding is the heaviest part since its supposed to simulate the complete bidding sequence and play sequence.

That code isn't in GIB, it's just the BBO server.

#20 User is offline   barmar 

  • PipPipPipPipPipPipPipPipPipPipPipPip
  • Group: Admin
  • Posts: 21,412
  • Joined: 2004-August-21
  • Gender:Male

Posted 2012-October-11, 18:35

View Postmycroft, on 2012-October-11, 17:56, said:

For BBO, I wouldn't worry about rand(); for people making hand records for Bermuda Bowl and the like, avoiding a PRNG is probably worth it - I postulated years ago that someone with $1M to build special hardware and access to the vugraph could likely crack a 36-deal set made from a single seed in time to know the last few boards. Computing power hasn't got *more expensive*.

So if JEC or Nickell wanted to cheat, they could afford to build that machine. I'm not too worried about it. It's still out of reach of some random player trying to win the BB.

  • 3 Pages +
  • 1
  • 2
  • 3
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users