Random Map Generator - Big Bug Fix Update (20/09), Builds Maps, Graphics and Lighting! Modular (GMK) |
This forum is for people to post information regarding their WIP projects for discussion and feedback. Note: by WIP projects, we mean those that are well underway, and we require that you post a demo. Make sure that you READ these rules prior to posting. Also, the General GMC Rules apply here too.
![]() ![]() |
Random Map Generator - Big Bug Fix Update (20/09), Builds Maps, Graphics and Lighting! Modular (GMK) |
Aug 31 2009, 07:57 AM
Post
#1
|
|
|
GMC Member Group: GMC Member Posts: 1950 Joined: 8-March 04 From: Australia Member No.: 6856 |
Hi All,
I am working on a random map generator for use in my game, I think the idea I have come up with is a pretty good one, and what I have so far shows it definately works. rather than keeping it to myself, I have decided to share this with you all to give you ideas for your own games, or even direct usage of this system (not in its current state) Current Features : Load Sections Save Sections Copy Sections Six tile types Generation via map "entry" points queue system for map generators to remove "freezing" during calculations Future Features : Forced joining of map parts map checking *in progress Section types *in progress complexity and ratio settings for map generator complete conversion into scripts output generated map to file *in progress set tile and grid size *in progress what it does/how it works : the "Section Creator" allows you to build sections of map, things like halls, rooms, intersections, etc for use by the map generator, these sections are saved into an external text file. the entire data for all the sections are stored in a single 2D array. when the map generator starts, it places random_generators on each edge of the map (entry points) using all available space it can. as this is designed to be used with the game in my signiature, there were a few pre-requisites that the engine requires for map graphics generation. these have been built into this generator, and are : sections MUST have at least 1 empty square on each side for wall graphics to fit doors can only be located on horizontal or vertical lines, not in corners etc tiles are 80x80 in size USAGE : when you start the program up, it will automatically load up the sections stored in SYSTEM\sections.arr file into memory, and then start the section builder. inside the section builder LEFT CLICK will place a tile and RIGHT CLICK will delete a tile. The TYPE buttons in the top/left currently dont work. SAVE will save the current section to memory, RELOAD will load up the current section in memory, NEW SECT will add a new section to the end of the array. COPY AS NEW will copy the currently viewed section as a new one, SAVE TO FILE will take all sections in memory and output them to SYSTEM\sections.arr Finaly RANDOM TEST will take you to the test map generator room. Pressing LEFT/RIGHT will move through the sections in memory In the test generator room, SPACE restarts the generator, Escape quits Currently the map generator uses a room which is 2480x2480 in size, I have tested it and it works on rooms as large as 10240x7680! maps that large take around 10-20 seconds to generate. here are a few screenshots : ![]() This is an image of the section creator, building a section is as easy as choosing a tile type and placing it around the starter arrow (but not over) ![]() This is an image of the map generator while it is building a map ![]() SUPER LARGE completed map, 10000x10000 in size WHOA! This is a fairly early version, which I am working on daily to get a refined and easy to use system as I need a random generator that can build a grid of maps totalling 400+ maps for my games main campaign. New update : mainly bug fixes save button, and save file button now show message when save is completed deleting the sections.arr file no longer gives errors. a new blank file will be created with a single tile on a single section creator will make system folder if it does not exist, rather than crashing font correctly set in creator re-ordered objects commented many lines of code in creator and randomizer groups cached dynamic room lights now standard room light when returning to the section creator, the last section edited will now be shown, rather than the first first attempt to completely remove "bad corners" in place replaced player object sprite with pretty terminator graphics (couldnt resist) DOWNLOADS : Random Generator + Lighting + Graphics Ver 15 (Latest) Must be unzipped including subfolders. The section file is located in SYSTEM folder and is called sections.arr. if the file is missing, it will create one with no data in it How maps are generated : the generator places down a random map section at the start point, any joiner tiles create another generator ontop of themselves. this generator shuffles the list of sections, and shuffles the list of directions, and then attempts to fit the first piece in the section list trying each angle, if this does not fit, it moves to the next section in its list until it either finds one that fits at a certain angle, or runs out of sections. this is done over and over again until no more random generators are left in the map room, the random generator controller then goes through all the tiles, removing the blank tiles, and checking doors for consistancy Any feedback, suggestions are welcome! This post has been edited by templargfx: Sep 20 2009, 03:06 AM |
|
|
|
Aug 31 2009, 10:43 AM
Post
#2
|
|
|
I miss my cupcake Group: GMC Member Posts: 1049 Joined: 22-November 03 From: Tokyo, Japan Member No.: 2488 |
Nice.
Haven't had a good look through the code yet, but works fast enough & I like the random outputs. Always been interested in these kind of random generators... interesting to see! Would love to see something like this paired with a traditional SNES Zelda type game or something... but best of luck with your project. Space Hulk is good stuff! |
|
|
|
Aug 31 2009, 02:42 PM
Post
#3
|
|
|
GMC Member Group: GMC Member Posts: 457 Joined: 16-August 04 Member No.: 13014 |
This looks really cool, I'd love to use try and create a game with it in the future when I have some spare time. I love randomly generated content in games. I haven't downloaded it as it seems pretty straight forward. Can it use a seed (a number that will return the same "random" result everytime)? if not that would be a nice feature.
|
|
|
|
Aug 31 2009, 11:17 PM
Post
#4
|
|
|
GMC Member Group: GMC Member Posts: 1950 Joined: 8-March 04 From: Australia Member No.: 6856 |
I would not have the faintest clue how to get it to do that, mainly due to the amount of random actions that are taking place.
each time a joiner is placed down, that joiner randomly shuffles the list of sections, and randomly shuffles the list of directions, then tries each section one after the other, attempting the current section at each angle in the shuffled list. I will investigate this idea a little later on, once I have the actual creation side completed |
|
|
|
Sep 1 2009, 02:30 AM
Post
#5
|
|
|
GMC Member Group: GMC Member Posts: 222 Joined: 21-March 07 From: The Void Member No.: 74075 |
It's nice to see someone is doing something besides a zombie shooting-weak anime rpg-block platformer-tired zelda clone.
I like the way it sorts through options to find a section that fits; great solution to ensure the map fills up the area. To head_removalist's point a seed would be great to reproduce good maps without needing a save file, but the save function serves the purpose. My only recomendation would be that it appears to generate more hallways than actual rooms, which depending on the game could be good, but if you think about it who would build something like that? As a RPG designer, I like to ask a question about every area I build, "what is the purpose of this dungeon?", "what is the purpose of this room?", "what function does this passage serve?" Maybe I overthink it too much, but I think that makes the environment more believable and more immersive. |
|
|
|
Sep 1 2009, 03:55 AM
Post
#6
|
|
|
GMC Member Group: GMC Member Posts: 1950 Joined: 8-March 04 From: Australia Member No.: 6856 |
Grey Matter, you are very right, I am of the same kind of thinking.
At the moment each section has a type, which is a simple number. I have been working on activating these types (you will see there are buttons for them in the section creator) but at the moment they are all of type 0. this will change very soon I did this so that when the generator is placing pieces, it can count how many halls/rooms there are, and how many, say, consecutive hall pieces have been placed one after another, and only choose a section of an oppropriate type to prevent "hall only" maps. which happens sometimes Here is a picture of a 10,000x10,000 map using a simple 9 section set.
This post has been edited by templargfx: Sep 1 2009, 05:00 AM |
|
|
|
Sep 2 2009, 01:04 AM
Post
#7
|
|
|
GMC Member Group: GMC Member Posts: 1950 Joined: 8-March 04 From: Australia Member No.: 6856 |
Here is an image of a map created by this, put into my graphics generator for Space Hulk.
This post has been edited by templargfx: Sep 4 2009, 11:34 PM |
|
|
|
Sep 4 2009, 11:38 PM
Post
#8
|
|
|
GMC Member Group: GMC Member Posts: 1950 Joined: 8-March 04 From: Australia Member No.: 6856 |
![]() Random Map Generator + Lighting (GMK Download) (code not optimized) Here is the latest version, all the new stuff is not commented or tweaked yet, but you can still see how its all done. New Stuff : Lighting Engine Added Randomizer starts on centre large room section set room size on random generator view random room as full map, or 1:1 re-ordered tile types tiles are now moved to background tiles once generation is complete |
|
|
|
Sep 8 2009, 04:09 PM
Post
#9
|
|
|
Game Maker Community Group: GMC Member Posts: 331 Joined: 30-October 03 Member No.: 1067 |
I would not have thought of using prebuilt sections -- rotating them at times too -- and making a random dungeon out of it. Interesting, I imagine that recent commercial roguelikes probably do similar things (Diablo 2 has obvious "prebuilt sections", now that I think about it).
It's cute, and beats what I was doing myself. I would think it better for there to not be rooms close to eachother by a diagonal space, though. Just seems like there wouldn't be any room for an actual wall if there are two rooms close to eachother diagonally but not vertically/horizontally... Well, I guess there would be room, if the walls were included inside the actual squares. Can you clear that up, since there aren't any visible walls once the Map is finished? However... I find it quite difficult to understand how your coding comes together, as there isn't much in terms of comments and design information. And why are you using alarms during the generation process? Another question. How many cells max do you think this could handle? In the first post you say "10000x10000 room", and as pretty as the screenshot is, the tiles in the GMK seem to be about 80x80 -- that's about 125x125 cells. How high can it really go in cells? Also, there seems to be an enormous amount of instances (almost 3000 in a 4000x4000 room) during the generation process, but it goes down to less than 100 afterwards --- even though I can *COUNT* more than 100 squares! What happened? Did you decide to go on a picnic and eat the remaining squares? I would think it to be better to simply use ds_grids rather than instances during the creation process... Or is there something particular about instances? Perhaps you're using them to make surfaces out of to conserve instance number after the generation process is over... Well, I can't quite figure the code out, since it's not mine and there isn't much commenting. Stuff can get confusing at times. Have fun. |
|
|
|
Sep 10 2009, 12:10 AM
Post
#10
|
|
|
GMC Member Group: Posts: 293 Joined: 10-October 08 Member No.: 116978 |
I would not have thought of using prebuilt sections -- rotating them at times too -- and making a random dungeon out of it. Interesting, I imagine that recent commercial roguelikes probably do similar things (Diablo 2 has obvious "prebuilt sections", now that I think about it). It's cute, and beats what I was doing myself. I would think it better for there to not be rooms close to eachother by a diagonal space, though. Just seems like there wouldn't be any room for an actual wall if there are two rooms close to eachother diagonally but not vertically/horizontally... Well, I guess there would be room, if the walls were included inside the actual squares. Can you clear that up, since there aren't any visible walls once the Map is finished? However... I find it quite difficult to understand how your coding comes together, as there isn't much in terms of comments and design information. And why are you using alarms during the generation process? Another question. How many cells max do you think this could handle? In the first post you say "10000x10000 room", and as pretty as the screenshot is, the tiles in the GMK seem to be about 80x80 -- that's about 125x125 cells. How high can it really go in cells? Also, there seems to be an enormous amount of instances (almost 3000 in a 4000x4000 room) during the generation process, but it goes down to less than 100 afterwards --- even though I can *COUNT* more than 100 squares! What happened? Did you decide to go on a picnic and eat the remaining squares? I would think it to be better to simply use ds_grids rather than instances during the creation process... Or is there something particular about instances? Perhaps you're using them to make surfaces out of to conserve instance number after the generation process is over... Well, I can't quite figure the code out, since it's not mine and there isn't much commenting. Stuff can get confusing at times. Have fun. Agreed. |
|
|
|
Sep 10 2009, 09:45 AM
Post
#11
|
|
|
GMC Member Group: GMC Member Posts: 1950 Joined: 8-March 04 From: Australia Member No.: 6856 |
Hi there,
you are correct, I use instances for 2 reasons, my graphics generation, which uses tiled map-wide instance with surfaces at 512x512 to store all room graphics, and give a base for all permenant special effects to be drawn to (blood, dead bodies, bullet holes etc) and for my level masks, which are another set of 512x512 tiles surfaces that subtract all the instances sprites from a black surface, this is then converted into a mask for that tile instance. this gives a complete outer border for collision detection, and can also be used as destructible terrain with ease. my coding style is very sloppy, when I create open source stuff I fix it up and comment it only once Im happy with how it works, as I often change/re-write entire snippets several times. the corner problem you are talking about have been fixed about 90%, it took me a while to figure out how these few that still remain were happening, but then it dawned on me that its the joiners being used as corner tiles that is causing it. I havent changed the section placement script yet to fix this tho. as for why I use alarms, I know it slows the overall creation process by about 100 steps, the delays are like they are so I can visually see when each section of the creation process ends. In the latest version, most of the alarm event creation stuff has been moved into a single room_controller which will handle all the different aspects. and allow you to enable/disable lighting/graphics creation here is the latest version, still no more commenting. I really just release the gmk at this early stage because its much smaller than the exe. ![]() dynamic lighting and graphics generation from external sprites New stuff : Graphics Implemented Lighting Implemented Movable object for exploring maps easily change view from full room to fixed view size easily change test room size Map thunbnail created and shown in top-right corner note on graphics system : the graphics system builds it graphics by first creating a large number of instances, each with an appropriate sprite to represent a wall, floor, floor detail, inner corner and outer corner. these are then used by grid_controller object to be subtracted from the surface stored in the blocker_surface objects tiled across the room to create an outer mask used for collisions and boundaries in game mechanics. note on lighting system : this is still in early stages, it works fairly well, but still needs alot of improvment, and several drastic bug fixes, the two main ones are : memory usage build-up on multiple room restarts after graphics has been created, semi-dynamic room lights seem to only draw one door shadow at a time, I have no idea why! (yet) Doors turn red when opening and blue when closing, semi dynamic lights only update when they are one of these colors. also doorway is drawn, but I havent copied the door sprite onto the doorway yet (used to be 2 seperate objects) note of random generator : working quite well, still has a bug of creating corners to close due to joiners being used as actual corners. also when a room starts, sometimes it places the first section outside of the room (dont know why yet) causing either the player_object to be placed on no floor tiles and/or nothing being generated. press space to generate a new map Random Map Generator with Graphics Generator and Lighting System (GMK Pro req) ***EDIT*** - Re enabled dynamic rooms lights, OOPS! use below edit stamp to decide if you need to re-download! how to use : Section creator room Left Click to place a tile, or choose a type of tile from the right side menu Right Click to remove a tile (can be held down) the random test button now says Room View or Normal View, to change the type, right click (you can change the size of the view square by modifying light_surface objects create code) Random Test room WSAD or Cursor Keys control the blue player_controller object which has a dynamic light attached pointing forward. used to explore maps. represented as red dot on map Space generate new room please give me feedback on the performance on your computer, and its specks so I have a better idea of the level of improvement required! This post has been edited by templargfx: Sep 10 2009, 09:56 AM |
|
|
|
Sep 13 2009, 11:46 AM
Post
#12
|
|
|
GMC Member Group: GMC Member Posts: 1950 Joined: 8-March 04 From: Australia Member No.: 6856 |
*bump*
I am currently finishing up a full-time cached light system for the room that will remove the heavy cpu load from doing it on-the-fly here is an example : Fake Door Lighting test (GMK Pro) ![]() Random Generator + Graphics Generator + Cached&Dynamic Lighting download this GMK to see the huge performance gain using cached room lights! This post has been edited by templargfx: Sep 13 2009, 02:52 PM |
|
|
|
Sep 20 2009, 01:47 AM
Post
#13
|
|
|
GMC Member Group: GMC Member Posts: 6 Joined: 18-January 09 Member No.: 126907 |
hey, and thanks for pointing me this way!
this looks extremely promising for use in my future project, however i had some troubles using the editor. i added a new section via "copy as new", edited it some, pressed both 'save' and 'save file', then tried a random test. didnt see my section so i pressed esc to get back to the editor, only to find that the section i edited had reverted to the way it was before i edited it. also, how do i start from a clean slate? i tried removing the sections.arr, but that gave me some errors on startup, ignoring those i came into a room without the buttons on the right. is there any way to view the level in 1:1, as in your screen above? and that mini map looks tasty, how do i get that? or maybe its not included in the editor? i get some smaller graphical glitches also, when i startup it looks like this: ![]() after doing a random test the font goes back to normal, but the tiles are still a bit 'zoomed out'. some suggestions: a message after you've pressed save or something, so you know its actually been saved a delete section button would be nice after doing a random test, it'd be really nice to get back to the section you were working on, rather than the first one i havent looked much at the code, but maybe the level generation could be sped up by increasing the room speed while generating? edit: ok so i tried the file in your last post (section_creator_lighting13.gmk), and the mini map is there, but when a level is done generating it looks like this:
This post has been edited by dyze: Sep 20 2009, 01:59 AM |
|
|
|
Sep 20 2009, 02:59 AM
Post
#14
|
|
|
GMC Member Group: GMC Member Posts: 1950 Joined: 8-March 04 From: Australia Member No.: 6856 |
New update :
mainly bug fixes save button, and save file button now show message when save is completed deleting the sections.arr file no longer gives errors. a new blank file will be created with a single tile on a single section creator will make system folder if it does not exist, rather than crashing font correctly set in creator re-ordered objects commented many lines of code in creator and randomizer groups cached dynamic room lights now standard room light when returning to the section creator, the last section edited will now be shown, rather than the first first attempt to completely remove "bad corners" in place replaced player object sprite with pretty terminator graphics (couldnt resist) Random Generator + Lighting + Graphics Ver 15 (Latest) REPLY TO DYZE : the save buttons not working is a bit of a mistery, it does it sometimes for no reason. I have added in a message popup as you suggested! To start from a clean slate, delete the sections.arr file, and it will create you a blank one. I will be adding in the ability to create/load from multiple section files soon To get the 1:1 view, right click the random test button (I have added some graphics making this more obvious) the section creator is supposed to look zoomed out like that, it allows you to place more tiles on a section, without needing to scroll around (which you cant do) unfortunately the only way to speed up map generation is to remove the ds_list execution of random_start_obj code. but this causes your game to completely freeze until it is complete. what I need to do is further optimize the quick_place script so that it better detects blocked section placement at less cpu cost your attempt to use section_creator13.gmk failed miserably because I stupidly forgot to include the graphics in the file. so it had no external graphics to load for the level as for your suggestions : messages on saving is done delete button is not there yet LOL section creator now returns to last viewed section |
|
|
|
Sep 20 2009, 03:26 AM
Post
#15
|
|
|
GMC Member Group: GMC Member Posts: 6 Joined: 18-January 09 Member No.: 126907 |
wow, that was quick!
about to go to bed so i only had a quick look. mini map works i started up, pressed random level, and it started to do it's thing, the graphics shows, but when it seemed almost finished, i got this: CODE ERROR in action number 1 of Alarm Event for alarm 1 for object grid_controller: Error in code at line 6: instance_activate_object(room_light); at position 29: Unknown variable room_light and later while trying to create a new .arr file from scratch, i got this after pressing save to file: CODE ___________________________________________ ERROR in action number 1 of Mouse Event for Left Pressed for object save_file_button: Error in code at line 8: file_text_write_string(section_file,'global.section_array['+string(i)+','+string(ii+1)+'] = "'+global.section_array[i,ii+1]+'"') at position 108: Unknown variable section_array or array index out of bounds sorry to ruin your quick update :/ dont know if this is possible, but one thing that would be awesome, would be if when say pressing save, the editor could automaticly place "empty - nothing allowed" tiles where appropriate. might be hard to do (?), but would save time and energy when creating sections. ok going to bed now, ill check it out further tomorrow. keep up the good work! |
|
|
|
Sep 27 2009, 01:04 PM
Post
#16
|
|
|
GMC Member Group: GMC Member Posts: 1039 Joined: 15-February 04 From: QUEBEC! ...canada... Member No.: 5972 |
Oh then, I see! This is pretty good, I like the lighting!
Also, your random map generating is sexy! Always in quest to find a good program to assist table gaming! |
|
|
|
Oct 5 2009, 11:35 PM
Post
#17
|
|
|
GMC Member Group: GMC Member Posts: 275 Joined: 11-August 05 Member No.: 33075 |
Wow, this is amazing. Probably the only lighting system I've seen that actually works on my Vista PC.
Keep up the good work, love to play something using this system. |
|
|
|
Oct 18 2009, 08:34 AM
Post
#18
|
|
|
GMC Member Group: GMC Member Posts: 25 Joined: 12-September 07 Member No.: 88323 |
Very nice. I'm working on something similar, but my code is awfully SLOW, especially if compared to yours. I hope you will finish it.
|
|
|
|
![]() ![]() |
|
Lo-Fi Version | Time is now: 9th February 2010 - 04:35 PM |