FAQ Database Discussion Community


How to check each element in array?

c++,arrays,maze
I'm trying to analyze each element that has been placed into my array from a txt file of chars for a maze game. The array must be checked so we can determine where in the maze the walls are, players are, ghosts, keys and ladders, entrance, etc. So I need...

Missing nodes in solution (maze DFS solving algorithm)

java,algorithm,depth-first-search,maze
I have a problem with my DFS algorithm missing nodes from solution (check image). It happens every time my algorithm encounters a dead end: the node is poped from stack to go back till available move is found, and is never reincluded again. Is there a easy way to fix...

Need help Implementing maze into 2d array c++

c++,arrays,2d,maze
So Im creating a treasure hunting game where the user moves through a maze with hidden health and traps. The goal is to find the treasure without dying. However, I need to create a map and I have a map I generated. I was wondering if there was a way...

Is it possible to store a struct into a linked list?

c,struct,stack,maze
I'm writing a program that solves a maze using DFS algorithm and stack. I was thinking of storing the coordinates of the path used to get to the end onto a struct containing integers x,y for coordinates and then pushing that struct onto a stack to perform other instructions on...

Find specific character in txt file for maze

c++,maze
I'm trying to setup a function that gets the Entrance of a maze from a text file, the char in the txt file is an 'E'. This needs to be used as the starting position for the player but I'm not sure how to identify a certain character in a...

FInd a path through a maze using recursion

recursion,path,maze
I just have a question about recursive methods. There is this method that I need to write that finds a path through a maze. However, it doesn't take any parameters. So I am wondering can a method that takes no parameters, be recursive?

Reading from file and writing to 2D vector

c++,vector,2d,maze
When i tried to print my 2D vector, it's only read 3rd line (which is first line of maze) and ignore rest of maze. My maze is something like that; 11 11 X XXXXXXXXX X X 1 X X XXXXX X X X X X 1 XXXXX XXX X X...

Solving maze with Backtracking

scala,backtracking,maze
I am trying to solve a maze with scala using backtracking. My problem is that I keep on getting StackOverflow errors. I have tried qite alot of things but I always end up with a StackOverflow. findStart() and the getWay() show two approaches I have used. I know that it...

How to make movable character in maze with C++

c++,user-controls,2d,player,maze
So I have my maze printed out once the user presses 1 in order to launch the map and other variables. I have declared the player as a smiley face or set equal to 1. However, I would like to make this character movable throughout the maze but am having...

Maze Backtracking Algorithm in C++ DFS?

c++,c,algorithm,depth-first-search,maze
I am new to C++ and I am currently on a project to create a maze that generates out using the DFS algorithm. I've already successfully managed to generate out a single path, which is for example 0 , 0 , 0 , 0, 0 0 , 1 , 1...

StackOverflow error due to recursion in Java

java,recursion,stack-overflow,maze
I'm attempting to use recursive methods to solve a maze represented by an int array of 1s and 0s in Java. wasHere[] checks if the method has already parsed that particular set of coordinates, correctPath[] records the answer path to the maze; both of them are initialized with every index...

2 dimensional maze solver recursive function

java,recursion,multidimensional-array,backtracking,maze
I am trying to implement a 2 dimensional matrix as a maze. There is a starting point, an ending point (randomly chosen). And to make it little complicated, there are obstacles and agents. If the rat runs into an obstacle, it should backtrack and find the correct path. If it...

Segmentation fault (recursion never ending) in C

c,recursion,backtracking,maze
I am trying to solve this problem: Given a Maze, it desired to find a path from a given starting position to the location with cheese (target position). Maze is visualized as a rectangular grid containing walls (represented as 1) or free ways (represented as 0). The program must print...

Get array size for use in for loop

c++,arrays,maze
I'm trying to get the size of my tiles array so it can be used in the for loop below. However, when compiling, it is showing that .size() is experimental in C++ 2011. What would be the best way to get the size in relation to this loop which checks...

Visiting Selected Points in a Grid before Reaching a Destination using BFS

algorithm,data-structures,shortest-path,maze,bfs
Alright so i was implementing a solution of a problem which started of by giving you a (n,n) grid. It required me to to start at (1,1), visit certain points in the grid, marked as * and then finally proceed to (n,n). The size of the grid is guaranteed to...

Finding path in a 2-d maze

c++,maze
Why is this code giving run-time error. I am trying to find if their exist a path inside the maze to reach the food(2). 0 representing obstacle, 1 representing path, and 2 is for the destination. `{0,1,1,0,0}, {1,0,1,1,1}, {0,0,0,0,0}, {0,1,1,1,1}, {0,0,1,1,0}, {1,0,1,1,2}` I'm passing the starting point as findpath(a,3,2) where...

How to read files in java?

java,file,filereader,maze
I made this maze solver program and all of it works except for the "file reader". What I intend to do is that the file has a maze map with 1 as a wall, 0 as a pass you can go, 3 is start and 9 is the finish line....