Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (757)
Games in Android Showcase (229)
games submitted by our members
Games in WIP (844)
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  
  Passable terrain paths algorithm?  (Read 5099 times)
0 Members and 1 Guest are viewing this topic.
Offline appel

JGO Wizard

Medals: 80
Projects: 4

I always win!

« Posted 2005-12-21 20:07:28 »

I'm making a game where the map is like 2048x2048, and each tile is about 16x16.
What I want to do is to have an random algorithm define what tiles are passable, and the rest are as default non-passable.

But I don't just want to define any random tiles as passable, I want them all to be connected to each other. Example:

Click to Play

How do I do this?
Offline DzzD
« Reply #1 - Posted 2005-12-21 20:33:47 »

maybe you can do that way

first you choose a starting pos x,y and set it to "P" then for each "P" pos you randomly select a neighbord and set it to "P" (if possible) and so on

EDIT: you can also randomly decide to do nothing for a  P , this will reduce the numbre of P


Offline appel

JGO Wizard

Medals: 80
Projects: 4

I always win!

« Reply #2 - Posted 2005-12-22 05:38:00 »

I was thinking more on the lines of creating a graph with random vertices in it (nicely distributed over the map), and then connect all the vertices with at least 1 edge (so they're all connected). Then I could simply "walk" the edge between the vertices and mark all the tiles the edge "touches" as passable.

But I don't know how to implement that, or if it's even a good solution to my problem.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline arne

Senior Devvie

money is the worst drug- we should not let it rule

« Reply #3 - Posted 2005-12-22 08:35:04 »

and then connect all the vertices with at least 1 edge (so they're all connected).

Nah - that doesn't have to work necessarily. You could also get loads of seperated subgraphs.

I think DzzD's way is the best for you. Maybe you could also add a variable that specifies how probably the path changes its direction and so on.

:: JOODE :: Xith3d :: OdeJava ::
Offline JAW

Senior Devvie

Medals: 2

« Reply #4 - Posted 2006-06-08 17:50:14 »

It depends a little on what kind of map you want to have. A labyrinth differs from a cave, and so on. Do you want it more closed or open? More straight lines and 90° turns or more fuzzy?

You could do a general algorithm which uses parameters. A parameter for wide or thin passable terrain, a parameter for more or less frequent turns in direction, a parameter for big or small changes in direction...

Two ways I could imagine:
1) You set a random starting position and start to "dig". You just define adjacent fields as passable based on some probability. You can use some restrictions for each field to check for constraints. For example you dont set a field passable if it would make the area too wide or if it would make a connection between two passable areas you dont want to connect.

2) First create random paths in your terrain, all with a width of 1. You can make more or less turns, longer or shorter paths, slight or great changes in directions. This gives you a path skeleton. Then widen the paths on your demand. If you want areas connected by small paths, select some fields on the paths and widen that area only. If you want wide winding paths, widen all fields for a small ammount.

Offline darkprophet

Senior Devvie

Go Go Gadget Arms

« Reply #5 - Posted 2006-06-12 11:06:32 »

If you used voronoi diagrams, you define "feature points" loop through the pixels, sort the nearest features from the current pixel and have coeffecient multipliers for each distance on.... An equation says a thousand words:

currentPixel = constant1 * nearestDistance + constant2* secondNearestDistance + constant3 * thirdNearestDistance...

Ofcourse, for performance reasons, i suggest you only need to use the first and second nearest distances, because you can take advantage of that if the first and second nearest distances are very very similar you end up (with the correct coeffecients) is a shallow (or high, depending on the coeffecients) point where pixels have a closely matching . Say if the first coeffecient was positive and the second coeffecient was negative, you would end up near 0 with equal distances.

So then, loop again through the pixels and only make the ones below a certain threshold passable and the rest, nonpassable. It gives a nice, organic feel to map if thats what you wanted.


Friends don't let friends make MMORPGs.

Blog | Volatile-Engine
Pages: [1]
  ignore  |  Print  

EgonOlsen (59 views)
2018-06-10 19:43:48

EgonOlsen (41 views)
2018-06-10 19:43:44

EgonOlsen (61 views)
2018-06-10 19:43:20

DesertCoockie (240 views)
2018-05-13 18:23:11

nelsongames (142 views)
2018-04-24 18:15:36

nelsongames (141 views)
2018-04-24 18:14:32

ivj94 (883 views)
2018-03-24 14:47:39

ivj94 (144 views)
2018-03-24 14:46:31

ivj94 (795 views)
2018-03-24 14:43:53

Solater (159 views)
2018-03-17 05:04:08
Java Gaming Resources
by philfrei
2017-12-05 19:38:37

Java Gaming Resources
by philfrei
2017-12-05 19:37:39

Java Gaming Resources
by philfrei
2017-12-05 19:36:10

Java Gaming Resources
by philfrei
2017-12-05 19:33:10

List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05 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‑
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!