From: Petter Fryklund <petter.fryklund@atero.se>
Subject: Re: Card game deck but with trumps suit for tarot "divination" Is there a better way than enumerating all cards?
Date: Tue, 6 Feb 2018 00:30:11 -0800 (PST)
Date: 2018-02-06T00:30:11-08:00 [thread overview]
Message-ID: <ee80a347-df10-42c7-b255-d7e44394effd@googlegroups.com> (raw)
In-Reply-To: <p52qrh$hev$1@franka.jacob-sparre.dk>
Den lördag 3 februari 2018 kl. 00:05:23 UTC+1 skrev Randy Brukardt:
> "Robert Eachus" <rieachus@comcast.net> wrote in message
> news:8c806572-009d-4ba2-a20d-de1209e45ca6@googlegroups.com...
> On Monday, January 29, 2018 at 6:17:01 PM UTC-5, Randy Brukardt wrote:
> ...
> >Why go through sorting the Long_Float values? If you draw without
> >replacement, you draw from 78 cards, then 77, 76, 75,...4,3,2,1. There
> >is nothing in Ada's random number generators to guarantee that these 78
> >generators work together to produce random values. By choosing 78
> >values from the same generator you don't have that problem.
>
> As previously noted, Ada 2020 has added an additional Random function into
> Discrete_Random to deal with this problem.
>
> An alternative approach using current Ada would be to use a fixed
> Discrete_Random range (0 .. 77), and simply discard any values that identify
> cards already dealt, just retrying to get a random value. This works well
> and is properly uniform, but only if you are going to deal part of the deck
> (say 25%). If you need to deal the whole deck, it can get slow toward the
> end when most of the values returned from Random have already been dealt.
> (That's especially bad if you forget to special case the last card to the
> dealt - you don't need a random choice to figure out which one that is after
> all of the rest have been dealt.)
>
> Experience shows that most users don't get this right, as did the discussion
> on the topic (in which many knowledgeable people suggested approaches which
> just don't work). I had to fix the Janus/Ada random number generator after
> that discussion, as it had made one of the mistakes as well.
>
> Randy.
When I generate bridge deals, I first draw cards for North this way, just drawing another if the card was already taken. Then I draw cards for East and South in the same way. West gets what is left.
Petter
next prev parent reply other threads:[~2018-02-06 8:30 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-28 7:48 Card game deck but with trumps suit for tarot "divination" Is there a better way than enumerating all cards? bozovic.bojan
2018-01-28 8:57 ` Jacob Sparre Andersen
2018-01-28 9:23 ` bozovic.bojan
2018-01-28 9:46 ` Jeffrey R. Carter
2018-01-28 14:17 ` bozovic.bojan
2018-01-28 16:39 ` Dennis Lee Bieber
2018-01-29 23:16 ` Randy Brukardt
2018-01-30 2:30 ` bozovic.bojan
2018-02-02 19:07 ` Robert Eachus
2018-02-02 23:00 ` Dennis Lee Bieber
2018-02-02 23:05 ` Randy Brukardt
2018-02-03 8:17 ` Jeffrey R. Carter
2018-02-03 16:59 ` Robert Eachus
2018-02-06 0:39 ` Randy Brukardt
2018-02-06 3:17 ` Robert Eachus
2018-02-06 8:30 ` Petter Fryklund [this message]
2018-02-07 20:03 ` Card game deck but with trumps suit for tarot "divination" Is there a better way Robert Eachus
2018-02-07 21:10 ` Bojan Bozovic
2018-02-08 23:06 ` Robert Eachus
2018-01-28 11:01 ` Card game deck but with trumps suit for tarot "divination" Is there a better way than enumerating all cards? gautier_niouzes
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox