View Single Post
Join Date: Jan 2008
Posts: 3,752
Reputation: VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute 
Solved Threads: 491
Featured Poster
VernonDozier VernonDozier is offline Offline
Senior Poster

Re: Need help in finding correct method for my program!

 
0
  #5
Nov 30th, 2008
Originally Posted by Nyaato View Post
Alright, noted and changed my void main() to int main(). Thanks for the advice!

I've use structs before, but not stacks. Haven't learned of that as of yet.

I'm still trying to figure out how to backtrack, as of what VernonDozier had suggested, but I'm not getting far at the moment...

If it's not too much, could I get an example of how it's like? Thanks again!
Here is a maze.
  1. *******
  2. ***
  3. * *
  4. * *****
  5. * *
  6. *******
  7.  
  8. Here is the correct path.
  9.  
  10. *******
  11. oo***oo
  12. *ooooo*
  13. * *****
  14. * *
  15. *******
  16.  
  17. Here is the attempt where you keep the wall to your right.
  18.  
  19.  
  20. *******
  21. oo***
  22. *o *
  23. *o*****
  24. *oooo@*
  25. *******
  26.  
  27. Oops, I hit a wall with a dead end. I have nowhere else to go, so I backtrack (i.e. go where I went before). I know that any spot where I've gone before and where I have no blank spaces and no option to switch directions is a dead end. Mark that dead end with an x so I don't go over it again.
  28.  
  29. *******
  30. oo***
  31. *o *
  32. *o*****
  33. *ooo@x*
  34. *******
  35.  
  36. *******
  37. oo***
  38. *o *
  39. *o*****
  40. *oo@xx*
  41. *******
  42.  
  43. and so on till I get to a spot where I have a new option.
  44.  
  45. *******
  46. oo***
  47. *@ *
  48. *x*****
  49. *xxxxx*
  50. *******
  51.  
  52. I'm back where I was before. Go right again.
  53.  
  54. *******
  55. oo***
  56. *o@ *
  57. *x*****
  58. *xxxxx*
  59. *******
  60.  
  61. Keep going.
  62.  
  63. *******
  64. oo***oo
  65. *ooooo*
  66. *x*****
  67. *xxxxx*
  68. *******
  69.  
Solved! Blank space is where I haven't been. o is where I've been that may possibly be the route, x is where I've been that is definitely not the route, @ is where I am now. When you reach a dead end, turn around and leave x's in your trail until you have an option to go right again. Never go down a path with an x.

This is a trivial example, but hopefully it'll help. Again, draw it out on paper first till you get a better understanding. Don't skip any steps till you really understand it.
Last edited by VernonDozier; Nov 30th, 2008 at 12:03 am.
Reply With Quote