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-7-bit Path: g2news2.google.com!postnews.google.com!o2g2000prl.googlegroups.com!not-for-mail From: Adam Beneschan Newsgroups: comp.lang.ada Subject: Re: Newbie question Date: Thu, 12 Mar 2009 11:29:53 -0700 (PDT) Organization: http://groups.google.com Message-ID: <601b0fd2-86cb-4c25-ae02-f0ce93fd20c4@o2g2000prl.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: 66.126.103.122 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: posting.google.com 1236882593 19129 127.0.0.1 (12 Mar 2009 18:29:53 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Thu, 12 Mar 2009 18:29:53 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: o2g2000prl.googlegroups.com; posting-host=66.126.103.122; posting-account=duW0ogkAAABjRdnxgLGXDfna0Gc6XqmQ User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.7.12) Gecko/20050922 Fedora/1.7.12-1.3.1,gzip(gfe),gzip(gfe) Xref: g2news2.google.com comp.lang.ada:5055 Date: 2009-03-12T11:29:53-07:00 List-Id: On Mar 12, 10:14 am, stefan-lu...@see-the.signature wrote: > > > type Piece_T(Color: Color_T) is > > > record > > > case Color is > > > when White => > > > White_Piece: Piece_Type_T; > > > when Black => > > > Black_Piece: Piece_Type_T; > > > when None => > > > null; > > > end case; > > > end record; > > > The problem with this is that you'd then need two code paths for > > Black_Piece and White_Piece, every time. > > Right. Actually, I anticipated that you would *want* two code paths for > the black and for the white pieces. I don't see why... I'd anticipate writing a subprogram like function Compute_Best_Move_For (Color: Color_T) return Move_T; [more accurately, instead of Color_T, we'd use a subtype that is a subrange of Color_T that allows only Black and White]. Now having two different paths would be an utter nuisance. Aside from the small detail that the pawns move in different directions, the algorithm would be exactly the same for both colors. In fact, I'd think most of the algorithms you would want to write that pertain to one particular player would work exactly the same for Black and White, except for pawn direction, and that can be dealt with by setting up some variable with value +1 for White and -1 for Black (or vice versa). -- Adam