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=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,e4042699db4db63b X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!news2.google.com!postnews.google.com!41g2000yqf.googlegroups.com!not-for-mail From: Ludovic Brenta Newsgroups: comp.lang.ada Subject: Re: Newbie question Date: Thu, 12 Mar 2009 07:31:07 -0700 (PDT) Organization: http://groups.google.com Message-ID: <02514f6d-81e0-4479-8433-08e9a0363d65@41g2000yqf.googlegroups.com> References: <49b90e2d$0$2847$ba620e4c@news.skynet.be> <0ff2f139-06cf-4fa5-8c0d-f97c43a33186@s20g2000yqh.googlegroups.com> <49b9193a$0$2854$ba620e4c@news.skynet.be> NNTP-Posting-Host: 153.98.68.197 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1236868267 13382 127.0.0.1 (12 Mar 2009 14:31:07 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Thu, 12 Mar 2009 14:31:07 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: 41g2000yqf.googlegroups.com; posting-host=153.98.68.197; posting-account=pcLQNgkAAAD9TrXkhkIgiY6-MDtJjIlC User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.7) Gecko/2009021910 Firefox/3.0.7,gzip(gfe),gzip(gfe) Xref: g2news1.google.com comp.lang.ada:4075 Date: 2009-03-12T07:31:07-07:00 List-Id: On Mar 12, 3:16=A0pm, Olivier Scalbert wrote: > Ludovic Brenta wrote: > > Solution 1: a variant record: > > > type Square_T (Empty : Boolean) is record > > =A0 =A0case Empty is > > =A0 =A0 =A0 when True =3D> null; > > =A0 =A0 =A0 when False =3D> Piece : Piece_T; > > =A0 =A0end case; > > end record; > > > type Board_T is array (1 .. 8, 1 .. 8) of Square_T; > > > Solution 2: merge the Boolean directly into Piece_T: > > > type Piece_T (Present : Boolean) is record > > =A0 =A0case Present is > > =A0 =A0 =A0 when True =3D> > > =A0 =A0 =A0 =A0 =A0Color : Color_T; > > =A0 =A0 =A0 =A0 =A0Piece_Type : Piece_Type_T; > > =A0 =A0 =A0 when False =3D> > > =A0 =A0 =A0 =A0 =A0null; > > =A0 =A0end case; > > end record; > > > Solution 3: introduce a new value for Piece_Type_T: > > > type Piece_Type_T is (None, Pawn, Knight, Bishop, Rook, Queen, King); > > > I don't know which is the best solution; perhaps you'd like to try > > them all and see how well they integrate with the algorithms. =A0I thin= k > > Solution 3 is the most error-prone, though. > > 3 solutions ! Thanks Ludovic. > > I like the first two solutions. With solution 3, you can have an empty > square (None) with a color. Come to think of it, you'll want to add default values to the discriminants in solutions 1 and 2: type Square_T (Empty : Boolean :=3D True) is record ... end record; or type Piece_T (Present : Boolean :=3D False) is record ... end record; This makes it possible to change the value of the discriminant square by assigning an aggregate, e.g. Board (5, 5) :=3D -- Solution 1 Square_T'(Empty =3D> False, Piece =3D> (Color =3D> Black, Piece_Type =3D> Pawn)); Board (5, 5) :=3D -- Solution 2 Piece_T'(Present =3D> True, Color =3D> Black, Piece_Type =3D> Pawn); I think I like solution 2 better, but then I'd rename Piece_T into Square_T. -- Ludovic Brenta.