Find The Way Out Problem, VB.NET 2003 - solution needed(

  • Thread starter Thread starter Totti
  • Start date Start date
T

Totti

Hi everyone,
I am asked to create a maze and to find a way out of it, as far as the
interface is concerned i am done, i have created a form, where using
arrays i created a maze that can be changed in size by user input of
rows and column.
I also have created a button to generate walls(push buttons in series)
inside the game so actually one push button can be of 2 phases "PATH"
or "WALL" depending on a randomizing algorithm. i also have a hard
coded IN and out where supposedly the maze will start and will go out.
Now, from here on i can use your help, i have done my research, i have
read many solutions and algorithms but my main problem is that i can't
figure out a way to implement them in VB. NET 2003 or to be honest, i
don't have the knowledge to do so, i thought on paper that some arrays
to see in which position the counter is, inside a while loop, that
check for "PATH" and changes direction on "WALL" could have been a
solution, but yet its pretty dificult for me to code it.

If anyone has any idea or any reference, on how i should do this thing
work, or if there is such a code found somewhere, Please provide some
help.Thanks in advance
 
Totti said:
Hi everyone,
I am asked to create a maze and to find a way out of it, as far as the
interface is concerned i am done, i have created a form, where using
arrays i created a maze that can be changed in size by user input of
rows and column.
I also have created a button to generate walls(push buttons in series)
inside the game so actually one push button can be of 2 phases "PATH"
or "WALL" depending on a randomizing algorithm. i also have a hard
coded IN and out where supposedly the maze will start and will go out.
Now, from here on i can use your help, i have done my research, i have
read many solutions and algorithms but my main problem is that i can't
figure out a way to implement them in VB. NET 2003 or to be honest, i
don't have the knowledge to do so, i thought on paper that some arrays
to see in which position the counter is, inside a while loop, that
check for "PATH" and changes direction on "WALL" could have been a
solution, but yet its pretty dificult for me to code it.

If anyone has any idea or any reference, on how i should do this thing
work, or if there is such a code found somewhere, Please provide some
help.Thanks in advance

One question that jumps out at me, if you are doing this in the way
described, is are you sure that you have a solveable maze? If you are
generating a random maze (walls or paths), that does not necessarily mean the
maze can be solved.

I believe a simpler approach is to gerate a random solution path first, then
fill in the remaining cells with random open/closed walls.

Mike
 
Mike you are right but the user has the right to click and make his
own wall and his own maze so what you suggested even though very
correct and i agree, will be left till the end.
What i need here is a loop that traverses the pushbuttons and checks
their states, and maybe keep the information that they have been
visited.when it comes to a dead end, it will look in the array for
somebody who can be traversable and go through it. till it reaches the
end where the pushbutton state is set to out. in the meanwhile, it
should write out the path somehow, i am thinking of changing the
pushbutton color to red or something
 
Mike you are right but the user has the right to click and make his
own wall and his own maze so what you suggested even though very
correct and i agree, will be left till the end.
What i need here is a loop that traverses the pushbuttons and checks
their states, and maybe keep the information that they have been
visited.when it comes to a dead end, it will look in the array for
somebody who can be traversable and go through it. till it reaches the
end where the pushbutton state is set to out. in the meanwhile, it
should write out the path somehow, i am thinking of changing the
pushbutton color to red or something

It isn't clear to me what your problem is: are you trying to figure out how
to set a wall the user has clicked or how to find if there is a solution
once the user has chosen where to place walls?

There appears to be much useful info here:
http://www.astrolog.org/labyrnth/algrithm.htm

Andrew
 
You are thinking walls but you really need to think in cells. The maze is
an aray of cells where each array element includes codes to indicate which
of its four edges are walls and which are not. If you build your maze like
this then it is relatively easy to keep track of where the taveller is,
which directions are valid for movement and whether or not the current cell
has the exit gap. It is also easy to check if the current cell is a dead
end. When you get to constructing your non-random maze it will be
constructed as an array - in fact the only algorithm I know for a perfect
maze (exactly one solution and that solution traverses the whole maze)
requires that it be built cell by cell and then wall by wall for each cell.

You would traverse the pushbuttons to build the current state of the maze
(although in practice the state could be maintained dynamically with each
button press). But for constructing and examinig the maze it needs to be an
array of cells.
 
Back
Top