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,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.36.28.11 with SMTP id c11mr14853203itc.41.1517131437126; Sun, 28 Jan 2018 01:23:57 -0800 (PST) X-Received: by 10.157.114.140 with SMTP id t12mr1303664otj.4.1517131437020; Sun, 28 Jan 2018 01:23:57 -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!feeder.usenetexpress.com!feeder-in1.iad1.usenetexpress.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!g80no397521itg.0!news-out.google.com!s63ni509itb.0!nntp.google.com!w142no400999ita.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Sun, 28 Jan 2018 01:23:56 -0800 (PST) In-Reply-To: <87y3ki743m.fsf@jacob-sparre.dk> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=87.116.179.50; posting-account=z-xFXQkAAABpEOAnT3LViyFXc8dmoW_p NNTP-Posting-Host: 87.116.179.50 References: <87y3ki743m.fsf@jacob-sparre.dk> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <40142b86-fdcf-49d3-bee7-2fdbb04c6db0@googlegroups.com> Subject: Re: Card game deck but with trumps suit for tarot "divination" Is there a better way than enumerating all cards? From: bozovic.bojan@gmail.com Injection-Date: Sun, 28 Jan 2018 09:23:57 +0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Xref: reader02.eternal-september.org comp.lang.ada:50191 Date: 2018-01-28T01:23:56-08:00 List-Id: On Sunday, January 28, 2018 at 9:57:34 AM UTC+1, Jacob Sparre Andersen wrot= e: > bozovic.bojan@gmail.com writes: >=20 > > These cards contain of 4 suits of 14 cards each, and special "trump" > > so called "major arcana" cards, 22 of them, for total of 78 cards. I > > created enumeration type and listed all 78 cards (with Tarot_Card'Pos > > of course 0..77 an Tarot_Card_Position in that range, and Deck as > > array(Tarot_Card_Position) of Card_Properties record with name and > > meaning fields. Using Ada.Numerics.Discrete_Random it works, but I > > wonder if better solution is possible)! When I've tried to make 4 > > suits of 14 cards and 22 cards in trump "suit" I however failed to see > > a solution and how I would iterate over such type, so I wonder if that > > route is possible. Thanks! >=20 > Why the mess with the type "Tarot_Card_Position"? You can make arrays > over enumeration types. >=20 > It sound like your problem space doesn't quite match a single > enumeration type, though. Maybe you really need a variant record? >=20 > type Card (Trump : Boolean) is > record > case Trump is > when True =3D> > Trump_Value : Major_Arcana; > when False =3D> > Suit : Suits; > Value : Values; > end record; >=20 > The naming is horrible, and the code is untested, but I hope you get the > idea. >=20 > Greetings, >=20 > Jacob > --=20 > "Good enough for physics" -- Ridcully Thanks for the input, I'll look into your suggestion, but the main problem = is each card has its "divinatoy meaning". I've used Tarot_Card_Position bec= ause it makes more sense to shuffle deck indexed in integer than in enumera= tion type and draw then a number of cars from it. But I know I wrote some a= wful code, as I really have little experience and no formal education. procedure Shuffle (TDeck : in out Deck) is position_gen : position_random.Generator; Temporary_Data : Card_Properties; Index_Random : Tarot_Card_Position; begin position_random.Reset (Gen =3D> position_gen); for Index in Tarot_Card_Position'First .. Tarot_Card_Position'Last lo= op Index_Random :=3D position_random.Random (Gen =3D> positio= n_gen); Temporary_Data :=3D TDeck (Index); TDeck (Index) :=3D TDeck (Index_Random); TDeck (Index_Random) :=3D Temporary_Data; end loop; end Shuffle; I make a Deck, Initialize it (with all 78 "divinatory meanings" of cards) c= all this Shuffle and draw then a number of cards. My code is not ideal, it = just happen to work, but I've did only some PHP programming and assembler p= rogramming back in 80s on 8-bit home computer.