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.

AppGameKit Classic Chat / procedural map generation

Author
Message
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 11th Jul 2017 07:47
I'm making a map of roads with intersections.

I have 5 different tiles: an intersection, a T junction, straight, a turn and a filler.

Tiles can (and should be for variety) rotated or flipped

How would i go about making a map where;
1. No road exits the map
2. No road abruptly ends. a road that exits a tile will join with a road on it's adjacent tile
3. The map doesn't look like a rats nest

Basically a map that would resemble an ordinary map of a village or town

PartTimeCoder
AGK Tool Maker
9
Years of Service
User Offline
Joined: 9th Mar 2015
Location: London UK
Posted: 11th Jul 2017 08:31
That's actually something I could use myself, a grid type and a preset type of road sections, seems like a worthy challenge, ok to use your image to experiment with?
PartTimeCoder
AGK Tool Maker
9
Years of Service
User Offline
Joined: 9th Mar 2015
Location: London UK
Posted: 11th Jul 2017 09:44 Edited at: 11th Jul 2017 09:44
This is unfinished, it places the border sprites I need to do the mid section but have to go out for a while so I thought I would post what I got so far maybe you can draw some ideas from it or simplify it a little, I will continue with the complicated part when I get home, this basically shows how I would go about structuring the code

blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 11th Jul 2017 10:04
looking good. happy for you to use the tiles. thanks for the help
i thought after the perimeter was done you could take a random number of points in the grid (Major roads). Then draw a road to the most distant edge on the grid. Vertical or horizontal depending on which is the most distant.
then you could try to draw a road (at right angles) from each point to it's nearest parallel neighbor road that crosses that point (if there are none then go to the edge)
i think that still needs another step to create some smaller roads but i'll try implement something
janbo
15
Years of Service
User Offline
Joined: 10th Nov 2008
Location: Germany
Posted: 11th Jul 2017 12:51 Edited at: 25th Jul 2017 22:43
For the mid section there comes autotiling or 4-bit bitmasking to mind then you start somewhere and branch from it like flood fill but with smart road type selection so...
left is the "look like a rats nest" problem.

Using AGKv2 Tier1
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 12th Jul 2017 05:09 Edited at: 12th Jul 2017 05:40
Thanks janbo, i'll look into that.

I did a little work on it (It's embedded in a larger proggy right now so i'll separate the code and post it later)

What i did was this;
1. Added a ring road around the entire map
2. I took 16 random points and created a road to the edge along the z or x axis depending on which was longest (as i hit other roads i created intersections and at the edge T joints)
3. I then went through those 16 points and erased the road until i came to an intersection. Depending on the surrounding blank space i made it a turn or a T

Issues
1. It can clump a bit so i need to space it out a bit more
2. I think i need to cull a few of the tiny intersections as well

Here are a couple maps



Attachments

Login to view attachments
PartTimeCoder
AGK Tool Maker
9
Years of Service
User Offline
Joined: 9th Mar 2015
Location: London UK
Posted: 12th Jul 2017 07:56
It looks good you done a great job, it looks like a typical "city block" setup, could almost be a overhead view of Manhattan island or Milton Keynes.
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 12th Jul 2017 08:23
Thanks. Your idea of thinking in lines really helped me visualize the process
GarBenjamin
AGK Developer
7
Years of Service
User Offline
Joined: 30th Nov 2016
Location: USA
Posted: 12th Jul 2017 15:36
@blink0k I think that looks very interesting. Well done!
TI/994a (BASIC) -> C64 (BASIC/PASCAL/ASM/Others) -> Amiga (AMOS/BLITZ/ASM/C/Gamesmith) -> DOS (C/C++/Allegro) -> Windows (C++/C#/Monkey X/GL Basic/Unity/Others)
29 games
18
Years of Service
User Offline
Joined: 23rd Nov 2005
Location: not entirely sure
Posted: 12th Jul 2017 20:45 Edited at: 12th Jul 2017 20:46
I've been having a think about, as I'm also doing a game that has procedurally generated levels (although mine actually need dead ends) and came up with a couple of ideas, one of which was to draw a road around the perimiter of the map and then draw roads between them.

My other other idea was to draw multiple, smaller rings that over lapped. However, this would generate a city that had corners and cross roads but no tee junctions.

So then I thought about deleting one random cell, then deleting any remaining "dead end" cells. I used you tiles to create a couple of examples of how this would end up looking.



The red cell is the random cell that is deleted and the blue the dead end cells. This then gives an irregular outer road which I thought would be more interesting.

You'd have to be carefull not to delete too many cells and end up with a map that became split up - I would do this by simply picking only one of two intial random cells.

You could also get an irregular outer road with one of your maps by applying the same method of picking a random cell from the current outer row and then deleting all the dead cells until you read a tee junction that would then be turn into a corner.

You could also apply this to one or two of the intersections.
Hover Car Race Challenge! - available now on Google Play
Invaders of the 29th Dimension - available now on Google Play
Find me on indieDB

Attachments

Login to view attachments
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 25th Jul 2017 03:56
Hey that looks very good. I think i'll add that as a "layer" to my process. Thanks!
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 29th Jul 2017 08:24 Edited at: 29th Jul 2017 08:50
Quote: "How would i go about making a map where;
1. No road exits the map
2. No road abruptly ends. a road that exits a tile will join with a road on it's adjacent tile
3. The map doesn't look like a rats nest"


It looks like your after a 3d version of road wrapping which I'm not sure of
but if your after a 2d version I have one at the following thread which may or may not help
https://forum.thegamecreators.com/thread/216193

and I was working on a RallyX style game which never got completed which used that style of approach
https://forum.thegamecreators.com/thread/216392 The youtube has since been deleted
but it was an example of an endless road map the source is there but its really just a more complex version
of the first link but with rotations etc

PS Never understood physics then, should redo the project

Goodluck and your roads look awesome BTW
fubar
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 29th Jul 2017 09:50
Great! Thanks!

Login to post a reply

Server time is: 2024-04-19 22:15:06
Your offset time is: 2024-04-19 22:15:06