# Thread: How would I complete this recursion algorithm?

1. ## How would I complete this recursion algorithm?

I've been working on something to solve this maze I read from a .csv file. I need an algorithm that traces a path from the start point (the green square) to the end (the red one). It can do this perfectly as long as it's only ever moving in a positive direction for either X or Y. I haven't been able to figure out how to continue to trace the path if it's moving in a negative direction, and seeing as how I've only been using C# for little over a year, I could use a second set of eyes. Any help is appreciated.

2. ## Re: How would I complete this recursion algorithm?

Algorithms are language independent, so what programming languages you do or don't have experience with is irrelevant, if you really are asking for help with an algorithm. If what you're really asking for is code in a specific language then you should be writing out your algorithm first. The algorithm is just a list of steps to perform and you can devise that with just a pen and paper. You can then test that algorithm manually on a drawn maze. Once you have a working algorithm, you then write code in the desired language to implement those steps specifically. If you're having trouble, you should be able to tell us exactly what step you need help implementing. If you're just trying to go straight from the idea in your head to code, without devising an algorithm first, then that's probably why you're having trouble.

Also, if you want to show us some code, you should start by posting the relevant code directly, as text, formatted as code. Links to ZIP files that probably contain your entire project (including the compiled binaries, which is against forum rules) should be a last resort. We should have to download, extract and open something and then work out for ourselves what's relevant. You should provide only what's relevant right in your post. If we need more, we can ask for it.

3. ## Re: How would I complete this recursion algorithm?

I wrote a recursive maze solver...

http://www.scproject.biz/puzzleGames.php?appId=22

The algorithm takes the endPoint and works one cell at a time checking all four possible directions, so it branches out from the endPoint and discards any dead ends, until it finds the solution...

4. ## Re: How would I complete this recursion algorithm?

Originally Posted by endlessBeggar
... I've only been using C# for little over a year, I could use a second set of eyes. Any help is appreciated.
If you are using C# you are in the wrong forum. One of the admins will move this if that is the case.

5. ## Re: How would I complete this recursion algorithm?

I removed the attachment. This forum doesn't allow posting compiled code. Please remove the bin and obj folders and re-attach. You don't need those folders anyways, as any person with VS could re-build, if they wanted to.

If you do want to do this in C#, I (or any other moderator) can move this thread there, but as JMC pointed out, the algorithm doesn't care which language you write it in. Figuring out a viable approach is language independent.

6. ## Re: How would I complete this recursion algorithm?

As others have said, the problem you're describing is language agnostic. I would like to add that what you're describing is called a path finding algorithm. It's an area that has been studied heavily and I have no doubt someone, perhaps some academic has long figured out a standardized way of doing it. There may even be multiple methods which work better under different circumstances. I'd advise that you Google it and see what's out there and you can then apply what you find to whatever language you're writing your maze solver in.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•