Author Topic: Recursive Path-Finding Madness  (Read 2355 times)

0 Members and 1 Guest are viewing this topic.

Offline Thundermagnet

  • LV3 Member (Next: 100)
  • ***
  • Posts: 69
  • Rating: +9/-0
  • Thundermagnet Productions
    • View Profile
Recursive Path-Finding Madness
« on: August 03, 2014, 10:44:46 pm »
Hello, O great reader!


On a serious note, for the past year or so I have spent countless hours re-writing a method, changing that method, and even re-writing the program from scratch.  I refused to try to get help, but I am finally caving.   :P


So!  Lets see if YOU can do it.  =)


What I have been trying to make is a recursive loop that will path-find through a unknown number of pipes.
There are three different pipes, all represented by three different numbers.  Pipe 1 runs north to south, and east to west.  Pipe 2 runs north to east, and south to west.  Pipe 3 run north to west, and south to east.


This recursive method is called "getTravelSpace", as it will trace its way along to grid of pipes until it comes to a space not occupied by a pipe.
(Asking for the code is not recommended, as I don't want someone to become confused over this.  Start with a clear mind!)  These pipes are randomly placed in a 10 by 10 grid, with each of these pipes receiving a random orientation (as in pipe 1, 2, or 3).


Pipes can run into the walls, and will wrap around to the other side.

The black spot (in the picture) is the pit, which SHOULD have a yellow circle around the four spaces around it if you follow any pipes that lead back to the pit.
The checkerboard-like pattern is actually the "closeToBeast" overlay, which SHOULD appear if you are within two moves of hitting the beast.
The whole problem could technically be the renderer, as it seems to take where the overlays should be and flip them over an imaginary line that runs from the top left to the bottom right of the window.

One other thing, the grid is an array of objects called "Space".  The Space class contains multiple methods for finding adjacent spaces, such as "getRelativeDir(int d)", which will find the wrapped relative space from the current space.


If you need more information to attempt the creation of this method, just let me know.


Thank you for any and all assistance,
Thundermagnet
« Last Edit: August 03, 2014, 11:02:47 pm by Thundermagnet »
Look me up on iTunes!  =D