Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Labyrinth code... problems with backtracking...!?

Author
Message
eLeit
21
Years of Service
User Offline
Joined: 15th Jan 2003
Location:
Posted: 15th Jan 2003 22:04
I am making a random labyrinth generator to be used in a small Dungoen RPG style game... unfortunately I can't quite get the backtracking to work. I have an eerie feeling that it's just some little detail, but I have looked at it till I was crosseyed and still couldn't get it to work... maybe you guys can help me?

It is supposed to go back through it's own track if it gets to a poing where it can go no further. Then when it goes back it should find a spot where it can go in a new direction and go forward again. This way it would generate a labyrinth that fills the whole array, and where you have access to all areas of the labyrinth.

Here's the code, hope you can help...

Fluffy Paul
21
Years of Service
User Offline
Joined: 16th Dec 2002
Location: United Kingdom
Posted: 16th Jan 2003 16:35
The best thing to do is to take your blank array and draw a random path from beginning to end. After you've done this you can then go an fill in the rest of it.

By the way - when you use the RANDOMIZE statement you are telling DB to generate random numbers based on the number you RANDOMZE with. If you always use the same number then you'll always get the same sequence of "random" numbers out of it. For this reason it's best to use a number that's always changing and is not likely to be the same twice - like the system time you get from the TIMER() function.

In addition, when using IF statements you don't have to say stuff like IF x=1 because 0 is always false and anything that isn't 0 is true. When you name your variables try to remember this so you can give them sensible names. You can just say IF x THEN do stuff if it doesn't matter what x is, just as long as it's not 0.

Login to post a reply

Server time is: 2024-05-17 04:56:02
Your offset time is: 2024-05-17 04:56:02