-1

Im developing 2d isometric game. You driving car on city, thats all. The issue is generating random maps with connected roads. I would like to write script - i think i will be able to - but i cant find an idea for alghoritm itself. Lets say i have 100x100 map, and i would like to build boolean table 1 is road 0 is not road.

As far i have solution that is drawing random number of lines (4-8 for ex) in horizontal and same vertical. But this road map is straight.

Can u share some ideas? Any will help

budda1989
  • 1
  • 3

1 Answers1

1

the question is too broad for a simple answer. theres plenty of ways in various degrees of complexity.

but as tip, consider the problem from a different perspective. sure in the end you want roads, but why are the roads there in the first place? in your case its a city. a city consists of city blocks wich usually are rectangular. so one way would be to find a way to fill the map with rectangular shapes and consider the edges roads (or only some).

or you could look into triangulation algorithms and triangulate your map with a bunch of random points. then combine some triangles and use those edges as roads.

or even only use a random walk set up so it doesnt turn around completely.

or ...

... seriously though, the options and possible solutions are manifold and dependent on your skill level (as well as how you want to look your city in the end). dont search for your specific problem, try to adapt some other algorithm for your need. theres plenty of tutorials on random dungeon generation for roguelike games. also in the end there probably wont be a single generation algorithm giving you the best result, but a combination of many.

yes
  • 967
  • 7
  • 12
  • Hello @yes and thanks for Your tips, i found some usefull information. I figured out some linear grid map with random size, and random map objects, here is effect :) [link](http://smilesoft.pl/images/games/roads.png) Thanks again and have a nice day! – budda1989 Apr 22 '16 at 17:33
  • @budda1989 looks good so far, now keep building on it. you have those roads and you know where they cross. now remove some of the roads in between 2 crossings again, this would break up the grid-nature a bit already. then you could have another pass checking for long roads for example and add a u-curve maybe, or grow a road splitting the block, or take a crossing and turn it into a roundabout. and thats just some ideas that instantly came to my mind. – yes Apr 22 '16 at 20:57
  • or you could also split the map in 2 (or 3) with a road from north to south. then split either side with a road (or two or 3) from east to west but each on a different height. then you split vertical again, then horizontal. do this a few times. then remove some roads, create some roundabouts, maybe grow a road on some very long straight pieces and so on´. also something not related, turn the arrows by 45°, atm one can only guess which direction they mean ;) – yes Apr 22 '16 at 21:13
  • wow thats a lot comments, what i meant to say, you dont have to generate the map in a single loop. you will probably get better results if you go over it 2-3 times. – yes Apr 22 '16 at 21:20