Results 1 to 6 of 6

Thread: How would I complete this recursion algorithm?

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2021
    Posts
    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.
    Last edited by Shaggy Hiker; Nov 30th, 2021 at 11:45 AM. Reason: Removed attachment.

  2. #2
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    107,905

    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. #3
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    24,508

    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. #4
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Pointless Forest 38.517,-92.023
    Posts
    9,419

    Re: How would I complete this recursion algorithm?

    Quote Originally Posted by endlessBeggar View Post
    ... 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.
    Last edited by Shaggy Hiker; Nov 30th, 2021 at 11:45 AM.
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

  5. #5
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    36,928

    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.
    My usual boring signature: Nothing

  6. #6
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    7,051

    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.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

Posting Permissions

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



Click Here to Expand Forum to Full Width