creating a random path

hey fellow JGOers,

I have been working on a tower defence, and it is going along quite well. Right now though, I am trying to have an option for randomly generated levels, this is so that the play is not restricted to the few levels included.

I have already tried this, the way I did it, was that I would create a spot, and then create an adjacent spot on an adjacent spot until there were no more spaces left, but this just left it in an infinite loop.

so basically, I am sure that there are some guys out there who done something like this b4, u dont even have to share your code, just could u tell me how you did it?

If you’ve got a list of tiles, just go through and fill them until you’re at the end.

For ideas on more complex methods like random maze generation, I found this pretty useful: http://en.wikipedia.org/wiki/Maze_generation_algorithm

thanks for replying,

for the first, do you mean like I was saying??

for the second, I had already seen stuff like that, but it isnt what I want, cause it creates a lot of extra paths as well, this is much simpler

Something like this perhaps?

I dont think that is quite what I am going for.

I will post a screen later, but right now I am abou to walk out the door.

basically what I am going for is a single path, and it generates the path, not the spaces blocking the path, and there are no side paths, just a random path from point a to point b, just think of like bloons(its a TD), it has a path going from the start tot he end, that is what I am going for, just randomly generated.

Sounds like you just need to work on your heuristics.
You don’t want a completely random walk, you want to guide it a bit.
Basically, pick a random starting position along one side.
Pick a direction to be facing.
Then, your choices are to walk forward and add to the path, or turn.
You can’t do two turns in a row.
You can only turn after walking for at least two.
You can’t walk onto the existing path.
If you get into a case where you cannot perform a legal move and you have not reached the goal point on the other side, you need to discard the path and start over

You can adjust the weight of the random between walking and turning to get lots of straight segments or lots of twisty segments.

ok, thank you. that is very helpful :).

so basically, I would just got through it with loops and have a few ints/boleans along wiht random ints to determine what to do next?