Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (539)
Games in Android Showcase (132)
games submitted by our members
Games in WIP (603)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  creating a random path  (Read 1900 times)
0 Members and 1 Guest are viewing this topic.
Offline h3ckboy

JGO Coder


Medals: 5



« Posted 2010-04-04 06:44:50 »

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?
Offline CommanderKeith
« Reply #1 - Posted 2010-04-04 07:41:36 »

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


Offline h3ckboy

JGO Coder


Medals: 5



« Reply #2 - Posted 2010-04-04 08:15:32 »

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
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline ryanm

Senior Devvie


Projects: 1
Exp: 15 years


Used to be bleb


« Reply #3 - Posted 2010-04-04 08:25:29 »

Something like this perhaps?
Offline h3ckboy

JGO Coder


Medals: 5



« Reply #4 - Posted 2010-04-04 08:30:53 »

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.
Offline Wildern

Junior Devvie





« Reply #5 - Posted 2010-04-05 01:41:20 »

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.
Offline h3ckboy

JGO Coder


Medals: 5



« Reply #6 - Posted 2010-04-05 06:23:19 »

ok, thank you. that is very helpful Smiley.

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?
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

rwatson462 (33 views)
2014-12-15 09:26:44

Mr.CodeIt (23 views)
2014-12-14 19:50:38

BurntPizza (51 views)
2014-12-09 22:41:13

BurntPizza (84 views)
2014-12-08 04:46:31

JscottyBieshaar (45 views)
2014-12-05 12:39:02

SHC (59 views)
2014-12-03 16:27:13

CopyableCougar4 (58 views)
2014-11-29 21:32:03

toopeicgaming1999 (123 views)
2014-11-26 15:22:04

toopeicgaming1999 (114 views)
2014-11-26 15:20:36

toopeicgaming1999 (32 views)
2014-11-26 15:20:08
Resources for WIP games
by kpars
2014-12-18 10:26:14

Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!