This is one of several user guides on specific topics. The directory for all user guides is here.
When you generate a random deal, or generate a deal from a shaper, the deal generator uses brute force to find a suitable deal. The random deal is the easiest of all because it shuffles the deck one time and that’s your random deal. When you generate from a shaper, the program starts with a random shuffle, then it examines the resulting deal to see if it conforms to your shaper. If it does, then there’s your deal. If it does not conform, then the program shuffles the deck and examines the next deal, and the next, and so on until it finds one that suits your shaper or else until it has shuffled the deck more than the number of times you selected in Maximum Number of Shuffles.
You can set that maximum number of shuffles to one of a list of values ranging from 10,000 to one hundred million. The default is one million, as shown above.
This setting exists because it is quite easy to use the Shaper and Cards panels to specify impossible deals.
If you try to generate a deal and you get an error dialog saying that you exceeded the maximum shuffles, that probably means that you have used the shaper to request not an impossible configuration, but one that does not occur often in nature. Say you specify 37 HCP in North, or a two-suited hand with zero HCP, or any number of unusual deals.
If you get such a warning, you can do one of several things: 1) change your shaper to something more likely; 2) use a fairly detailed recipe instead of the shaper; or 3) select a higher value for Max Shuffles and try to generate it again; or 4) give up—maybe you requested that odd configuration by accident.
One more thing about long-running generators: if you set “Number of Deals” to something other than 1, after hitting Max Shuffles on the first attempt the program will start over from zero shuffles on the next attempt and will probably hit the Max again, and so on until it has tried it for all of your Number of Deals. So if you make a shaper with 37 HCP in one hand, and you request 128 deals and you have Max Shuffles set to its highest value, be prepared to watch it run—and report failure—for a long time.
Hi Robin, thanks for looking in and commenting. My shuffling method is addressed here https://bridgecommaoutahead.substack.com/p/how-random-is-it-exactly. Folks who use something other than Javascript have solved this by using a random number generator that can generate an integer large enough to encompass the number of possible deals; they then convert that integer into a deal. You can see that since I only use Javascript, I rely on the window.crypto function that is available to all browsers--but that its degree of entropy is not guaranteed to be high enough for any given purpose. Not wanting to rely on just one call to that function, I call it 52 times and assign the resulting pseudo-random number to each card, then sort the deck on that number. A mathematician might look at that and tell me that using 52 pseudo random numbers does not improve on the potentially low degree of entropy from a single pseudo random number, but as a non-mathematician I did what felt like an improvement on using a single number. Each implementation of window.crypto obtains its seed from some source or other; therefore it varies by browser and possibly by operating system, and I don't control that--I just call window.crypto.getrandomvalues. I would like to know the actual degree of randomness of my method, but of course it's going to vary by platform and implementation of the window.crypto functions.
Can you tell me about how you do the shuffle? Do you use the "modified Fisher-Yates" algorithm (also known as Knuth's Algorithm P)? How do you choose the seed?