maze

Recursive brute force maze solver Java

情到浓时终转凉″ 提交于 2019-12-02 08:42:53
In an attempt to write a brute force maze solving C program, I've written this java program first to test an idea. I'm very new to C and intend to convert it after getting this right in java. As a result, I'm trying stick away from arraylists, fancy libraries, and such to make it easier to convert to C. The program needs to generate a single width path of shortest steps to solve a maze. I think my problem may be in fragmenting a path-storing array passed through each recursion. Thanks for looking at this. -Joe maze: 1 3 3 3 3 3 3 3 3 3 3 0 0 0 3 3 0 3 3 3 0 3 3 3 2 Same maze solved by this

Find all possible paths through a maze

安稳与你 提交于 2019-12-01 16:33:53
问题 I'm trying to create a program that will traverse a randomly generated maze where 1's are open and 0's are walls. starting in the top left and ending in the bottom right. The path can go up, down, left, and right. Currently, my program gives me a solution, but I'm having trouble getting it to print more than one path. I've read several different versions of this problem, but I'm unable to find one quite with my parameters. Here's my code, I omitted the part where I randomly generate my maze.

DFS shortest path of a maze in C++

二次信任 提交于 2019-12-01 12:40:31
I'm having trouble figuring out how exactly to get this to work... I'm attempting to get the shortest path to the goal using a DFS. I know that BFS is better but I was asked to use DFS for this. As you can see, I attempt to make a comparison between all stacks that lead to the end to find the goal, but it does not work, only the first stack that leads to the goal is ever printed... I know somewhere I need to unvisit nodes, but I cannot figure out exactly how. Right now I do get a path to the goal, but not the shortest one. Any help with this would be greatly appreciated. Writing a non

Algorithm to generate a segment maze

巧了我就是萌 提交于 2019-11-30 07:08:00
I want to generate a maze that looks like this: That is, it consists of paths in one direction that are then connected. I have looked for an algorithm to generate mazes like this without success. Specifically, I don't want a maze like this: because it doesn't "run" in only one direction. Also, it would be nice if the solution of this maze required the player to "backtrack" -- i.e. not just move upwards all the time. create a random path between point A and B randomly add walls as long as it doesn't lie on the path until you're satisfied Well that was fun! Complete with ASCII art output I

Maze solving with python

天大地大妈咪最大 提交于 2019-11-29 06:55:51
I am trying to make a maze solver, and it is working except that instead of the path being marked by "o" I want it to be marked with ">", "<", "v", "^" depending on the direction of the path. This is the part of the code where it solves the maze: def solve(self,x,y): maze = self.maze #Base case if y > len(maze) or x > len(maze[y]): return False if maze[y][x] == "E": return True if maze[y][x] != " ": return False #marking maze[y][x] = "o" #recursive case if self.solve(x+1,y) == True : #right return True if self.solve(x,y+1) == True : #down return True if self.solve(x-1,y) == True : #left return

How to find the fastest route in a maze (in C) [duplicate]

人盡茶涼 提交于 2019-11-28 13:05:58
This question already has an answer here: Programming theory: Solve a maze 14 answers The maze is defined as a square matrix. For example: int maze[N][N] = { { 1, 1, 1, 1, 1, 1, 1 }, { 0, 1, 0, 1, 0, 0, 1 }, { 0, 1, 0, 1, 1, 1, 1 }, { 0, 1, 0, 0, 0, 1, 1 }, { 0, 1, 1, 1, 0, 1, 1 }, { 0, 0, 1, 0, 1, 1, 1 }, { 1, 1, 1, 1, 0, 1, 1 } }; You can walk only where there's a 1. You can take a step down, up, left, right. You start at the top-left corner and finish at down-right corner. The output should be the minimum steps to finish any maze. We can assume there is at least one way to finish the maze.

How to generate a maze with more than one successful path?

时光毁灭记忆、已成空白 提交于 2019-11-28 11:46:13
Which algorithm can be used to generate a maze with more than one successful path and if algorithm is modified version of some well known algorithm then explain or add a link . I am using 2D array A to store configuration of maze . Assume if the size of maze is n * n then more than one path should be there from A[0][0] to A[n-1][n-1] . This algorithms should be able to generate mazes with distinct loop-free paths from start to goal: Starting with an empty maze (or a solid block of rock), with just the start and the goal... Subdivide the maze into three sets: Start (intially holding just the

Minimum distance between start and end by going through must visit points in a maze

旧街凉风 提交于 2019-11-28 11:39:06
问题 So, suppose i have a maze, which has a start point and an end point, marked with Orange and red respectively and my goal is to find the minimum distance between them. The blocked path is represented by black colour and the open path is represented by white colour . However there are two modification done in this. There are some cells which are must visit, marked in grey colour. Any cell can be visited any number of times(even the start, finish and must visit points) for ex- B=Black, W=white,

List.append() changing all elements to the appended item [duplicate]

假如想象 提交于 2019-11-28 11:15:48
This question already has an answer here: Why does foo.append(bar) affect all elements in a list of lists? [duplicate] 3 answers I seem to have a problem with my maze generating program made in Python. I'm trying to randomly create a path that branches out at select points, with the points getting stored as it goes along. When the maze gets to a dead end, it will sort back through the visited points by testing the top value than popping that and going to the next one, until it gets to a spot where it isn't a dead end. However, when I try to append items to the list I'm using to save the spaces

Maze solving with python

别说谁变了你拦得住时间么 提交于 2019-11-28 00:25:55
问题 I am trying to make a maze solver, and it is working except that instead of the path being marked by "o" I want it to be marked with ">", "<", "v", "^" depending on the direction of the path. This is the part of the code where it solves the maze: def solve(self,x,y): maze = self.maze #Base case if y > len(maze) or x > len(maze[y]): return False if maze[y][x] == "E": return True if maze[y][x] != " ": return False #marking maze[y][x] = "o" #recursive case if self.solve(x+1,y) == True : #right