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.224.75.137 with SMTP id y9mr12800102qaj.3.1367105939119; Sat, 27 Apr 2013 16:38:59 -0700 (PDT) X-Received: by 10.49.40.168 with SMTP id y8mr399010qek.9.1367105939092; Sat, 27 Apr 2013 16:38:59 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!mx05.eternal-september.org!feeder.eternal-september.org!news.glorb.com!s14no282699qam.0!news-out.google.com!ef9ni27140qab.0!nntp.google.com!s14no284389qam.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Sat, 27 Apr 2013 16:38:59 -0700 (PDT) In-Reply-To: <61f44636-ad71-447f-a20e-473e613f63ff@googlegroups.com> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=134.240.94.19; posting-account=CZZpzgoAAAAoaHoNNp9zhY9EzQgEmxhU NNTP-Posting-Host: 134.240.94.19 References: <87c89205-7fee-4d88-b4ab-08d26c03219b@googlegroups.com> <99d9a17c-ed8d-4c28-90d0-6543b511cb87@googlegroups.com> <4c3eca49-8ee6-4518-9968-879c08b828f6@googlegroups.com> <61f44636-ad71-447f-a20e-473e613f63ff@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <3772c50a-980d-4c82-8b15-8b1eec5e128e@googlegroups.com> Subject: Re: Depth First Search of a Char_Matrix? From: Alex Injection-Date: Sat, 27 Apr 2013 23:38:59 +0000 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Xref: news.eternal-september.org comp.lang.ada:15197 Date: 2013-04-27T16:38:59-07:00 List-Id: On Saturday, April 27, 2013 7:34:51 PM UTC-4, Shark8 wrote: > When you print the array out you have a representation of nodes (and impl= icitly edges), just displayed in a tabular ASCII format. >=20 >=20 >=20 > Is a very real sense (1,1), (1,2),...,(5,5) are merely addresses/location= s of a node, wherein 'B', 'W' and '.'/' ' denote that node's state the edge= s, then, ar nothing more than the relationship of what is adjacent in the h= orizontal/vertical. >=20 >=20 >=20 > ------------------------------------------- >=20 > [Non-DFS method] >=20 > You could count the dead pieces as follows: >=20 > if there are no empty locations all are dead, otherwise >=20 > (1) make two lists of nodes A & B, >=20 > (2) add all the empty nodes to A, >=20 > (3) for each node of A, add its neighbors to B if they are occupied, >=20 > (4) clear A >=20 > (5) for each of those nodes in B, add only its neighbors containing a pie= ce of the same color to A >=20 > (6) merge A into B >=20 > (7) repeat #4/#5/#6 until the sizes B is the same as it was in #4. >=20 >=20 >=20 > At this point the system is stable and you have all the live pieces in yo= ur list, anything not in your list is then dead. -- This would be a horribl= e way to do things on any large sized board because of the reiterations... = but it's already given you the secret of how to do it with DFS. Ok that makes a lot more sense and yes that set of steps has provided much = more insight into the DFS way to do things. Thanks!