From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.107.179.68 with SMTP id c65mr1192614iof.35.1517905812058; Tue, 06 Feb 2018 00:30:12 -0800 (PST) X-Received: by 10.157.112.141 with SMTP id l13mr70926otj.1.1517905811940; Tue, 06 Feb 2018 00:30:11 -0800 (PST) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!feeder.eternal-september.org!feeder.erje.net!2.eu.feeder.erje.net!border1.nntp.ams1.giganews.com!nntp.giganews.com!peer02.ams1!peer.ams1.xlned.com!news.xlned.com!peer02.am4!peer.am4.highwinds-media.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!w142no2041139ita.0!news-out.google.com!k194ni7575itb.0!nntp.google.com!o66no787898ita.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Tue, 6 Feb 2018 00:30:11 -0800 (PST) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=136.163.203.5; posting-account=g0yTkgoAAADdZGEYyZahxGlO3EkjH0Wv NNTP-Posting-Host: 136.163.203.5 References: <87y3ki743m.fsf@jacob-sparre.dk> <40142b86-fdcf-49d3-bee7-2fdbb04c6db0@googlegroups.com> <8c806572-009d-4ba2-a20d-de1209e45ca6@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: Card game deck but with trumps suit for tarot "divination" Is there a better way than enumerating all cards? From: Petter Fryklund Injection-Date: Tue, 06 Feb 2018 08:30:12 +0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Received-Body-CRC: 1887530730 X-Received-Bytes: 3651 Xref: reader02.eternal-september.org comp.lang.ada:50314 Date: 2018-02-06T00:30:11-08:00 List-Id: Den l=C3=B6rdag 3 februari 2018 kl. 00:05:23 UTC+1 skrev Randy Brukardt: > "Robert Eachus" wrote in message=20 > 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. >=20 > As previously noted, Ada 2020 has added an additional Random function int= o=20 > Discrete_Random to deal with this problem. >=20 > An alternative approach using current Ada would be to use a fixed=20 > Discrete_Random range (0 .. 77), and simply discard any values that ident= ify=20 > cards already dealt, just retrying to get a random value. This works well= =20 > and is properly uniform, but only if you are going to deal part of the de= ck=20 > (say 25%). If you need to deal the whole deck, it can get slow toward the= =20 > end when most of the values returned from Random have already been dealt.= =20 > (That's especially bad if you forget to special case the last card to the= =20 > dealt - you don't need a random choice to figure out which one that is af= ter=20 > all of the rest have been dealt.) >=20 > Experience shows that most users don't get this right, as did the discuss= ion=20 > on the topic (in which many knowledgeable people suggested approaches whi= ch=20 > just don't work). I had to fix the Janus/Ada random number generator afte= r=20 > that discussion, as it had made one of the mistakes as well. >=20 > Randy. When I generate bridge deals, I first draw cards for North this way, just d= rawing another if the card was already taken. Then I draw cards for East an= d South in the same way. West gets what is left. Petter