comp.lang.ada
 help / color / mirror / Atom feed
From: Alex <willmann817@gmail.com>
Subject: Re: Depth First Search of a Char_Matrix?
Date: Sat, 27 Apr 2013 15:54:40 -0700 (PDT)
Date: 2013-04-27T15:54:40-07:00	[thread overview]
Message-ID: <807cc2f4-b8d7-4003-815a-41df959aa909@googlegroups.com> (raw)
In-Reply-To: <b9ad77b9-3f23-4e80-88e1-92ddeefdb74a@googlegroups.com>

On Saturday, April 27, 2013 3:05:30 PM UTC-4, Shark8 wrote:
> On Saturday, April 27, 2013 10:51:44 AM UTC-6, Alex wrote:
> 
> > 
> 
> > Thanks! So I am given the function signature, not really a function body that looks like this
> 
> > 
> 
> >    function Count_Alive(Board : Char_Matrix) return Integer is
> 
> >  	M : Char_Matrix := Board;  
> 
> > 	begin
> 
> >       return -999;
> 
> >    end Count_Alive;
> 
> > 
> 
> > 
> 
> > So I understand much of your logic, but I am given a matrix of characters defined as such:
> 
> > 
> 
> > type Char_Matrix is array(Positive range <>, Positive range <>) of Character;
> 
> > 
> 
> > So could you give me like an algorithm in words on what I need to do instead of giving me the answer in code?
> 
> 
> 
> The algorithm is much the same, just substitute a "Piece'(Color=>Black)" for 'B', "Piece'(Color=>White)" for 'W', and the space/'.'/whatever for the null. (Your handling of null and such will have to change, but it's the same idea as in the code already given: there's a board-position that might have a piece, if it does that piece is either black or white and either alive or dead.)

I am just still a little confused.  I know how to do a DFS if I actually have a Graph Data Type with nodes and edges but I do not have that.  I am given the following

type Char_Matrix is array(Positive range <>, Positive range <>) of Character;

and

   function Count_Alive(Board : Char_Matrix) return Integer is
   begin
      return -999;
   end Count_Alive; 

The Char_Matrix will look something like this:

///////
/WW.BB/
/.WWWW/
/WWBBB/
/BBBWW/
/WWBW./
///////

A '/' is off the board, a 'W' is a white piece, a 'B' is a black piece and a '.' is an empty space on the board.  A piece is alive if it is next to an empty space ('.') or if it is next to an alive piece of the same color. What are the nodes and edges and how do you traverse this using DFS to count the number of Alive pieces and number of Dead pieces?  

  reply	other threads:[~2013-04-27 22:54 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-27 14:09 Depth First Search of a Char_Matrix? Alex
2013-04-27 15:35 ` Shark8
2013-04-27 17:25   ` Jeffrey Carter
2013-04-27 18:16     ` Shark8
2013-04-27 18:48       ` Dmitry A. Kazakov
2013-04-27 18:58         ` Shark8
2013-04-27 20:16           ` Dmitry A. Kazakov
2013-04-27 19:31       ` Simon Wright
2013-04-27 20:04         ` Shark8
2013-04-28  3:26       ` Jeffrey Carter
2013-04-27 16:27 ` Alex
2013-04-27 16:34   ` Shark8
2013-04-27 16:51     ` Alex
2013-04-27 16:55       ` Alex
2013-04-27 19:05       ` Shark8
2013-04-27 22:54         ` Alex [this message]
2013-04-27 22:56         ` Alex
2013-04-27 23:34           ` Shark8
2013-04-27 23:38             ` Alex
2013-04-29 20:55             ` Alex
2013-04-29 23:40               ` Jeffrey Carter
2013-04-30 10:49               ` AdaMagica
2013-04-28 10:50 ` AdaMagica
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox