CodeWalrus

Development => Calculators => Calculator News, Coding, Help & Talk => Topic started by: Keoni29 on August 13, 2015, 11:56:59 AM

Title: Random dungeon generation
Post by: Keoni29 on August 13, 2015, 11:56:59 AM
I am experimenting with random dungeon/world generation. The algoritm creates rooms in a 2d grid. When a room is created there is a chance that new rooms spawn in an adjacent empty spot. I used recursive code to implement this.
Title: Re: Random dungeon generation
Post by: Snektron on August 13, 2015, 09:59:59 PM
Looks pretty sweet. Maybe you can release the algorithm and allow user to make dungeons with it?
Title: Re: Random dungeon generation
Post by: Dream of Omnimaga on August 14, 2015, 11:28:15 AM
Very nice work. I am curious if you plan to use this in Herocore? How large is the program? It would be interesting if this could be made into a BASIC lib or something for people who wants to make Rogue-like games. :)
Title: Re: Random dungeon generation
Post by: Keoni29 on August 15, 2015, 12:22:52 PM
Quote from: Cumred_Snektron on August 13, 2015, 09:59:59 PM
Looks pretty sweet. Maybe you can release the algorithm and allow user to make dungeons with it?
Here is the AXE source code and executable attached down below.

Quote from: DJ Omnimaga on August 14, 2015, 11:28:15 AM
Very nice work. I am curious if you plan to use this in Herocore? How large is the program? It would be interesting if this could be made into a BASIC lib or something for people who wants to make Rogue-like games. :)
For Hero Core the algorithm would have to be expanded with item rooms and save rooms, barriers and bosses. This is very complex and it's probably better to make a world manually in a level editor. The program is smaller than 2k with absolutely no optimizations and fast compilation. It could probably be coded in BASIC as well. No need to make a library for it.

Edit: made a screenshot:
(https://codewalr.us/index.php?action=dlattach;topic=658.0;attach=491;image)
Title: Re: Random dungeon generation
Post by: Dream of Omnimaga on August 15, 2015, 06:13:35 PM
Looks very nice. As for BASIC I bet it would be extremely slow, though lol.

Maybe some sort of Zelda game with random dungeons and item placements for maximum replay value?
Title: Re: Random dungeon generation
Post by: Keoni29 on August 15, 2015, 06:16:10 PM
I read an article about zelda-like dungeon generation after I wrote my algorithm. It incorporates item-based puzzles in the generator.
http://bytten-studio.com/devlog//2012/01/21/procedural-dungeon-generation-part-i/
Title: Re: Random dungeon generation
Post by: Dream of Omnimaga on August 15, 2015, 07:14:49 PM
THis would be great if you could implement items in your map generator :P
Title: Re: Random dungeon generation
Post by: CKH4 on August 15, 2015, 07:25:44 PM
Wow this is awesome, I can't wait to see the code.
Title: Re: Random dungeon generation
Post by: Keoni29 on August 19, 2015, 07:29:32 AM
Quote from: DJ Omnimaga on August 15, 2015, 07:14:49 PM
THis would be great if you could implement items in your map generator :P
What you would typically do is put items in dead ends: rooms with just one entrance. You can seal these entrances with puzzles and locks that require other items. It's up to another algorithm to generate the contents of the rooms.

Quote from: CKH4 on August 15, 2015, 07:25:44 PM
Wow this is awesome, I can't wait to see the code.
Good news. You already could!
Title: Re: Random dungeon generation
Post by: CKH4 on August 21, 2015, 11:08:57 PM
I finally had time to look at the source and wow, I get about none of it. Maybe I'll be able to decifer some of it later. The speed is fantastic though. Good job on it.
Title: Re: Random dungeon generation
Post by: Dream of Omnimaga on August 22, 2015, 01:34:27 AM
Quote from: Keoni29 on August 19, 2015, 07:29:32 AM
Quote from: DJ Omnimaga on August 15, 2015, 07:14:49 PM
THis would be great if you could implement items in your map generator :P
What you would typically do is put items in dead ends: rooms with just one entrance. You can seal these entrances with puzzles and locks that require other items. It's up to another algorithm to generate the contents of the rooms.

Quote from: CKH4 on August 15, 2015, 07:25:44 PM
Wow this is awesome, I can't wait to see the code.
Good news. You already could!
Yep, items in dead ends is what I thought. You also have to make sure that related items are not too close to each others, though, such as for example if you scatter locked chests that can be only opened with 1 key, then scatter keys around. You would need to ensure that the keys are not right next to the chests they can open.
Title: Re: Random dungeon generation
Post by: CKH4 on August 23, 2015, 10:13:04 AM
Quote from: DJ Omnimaga on August 15, 2015, 06:13:35 PM
Looks very nice. As for BASIC I bet it would be extremely slow, though lol.l
Nope, I made a basic one using a map of random points (although it doesn't use path based but that could be added or faked easily).
(http://imgur.com/7UFOqrZ.jpg)
This takes about 10 seconds.
Title: Re: Random dungeon generation
Post by: Dream of Omnimaga on August 23, 2015, 03:39:49 PM
OOh that's not bad. I thought such stuff would be much slower. It would definitively be handy for people making BASIC Rogue-likes. Maybe @123outerme could implement it in Solius?
Title: Re: Random dungeon generation
Post by: CKH4 on August 23, 2015, 03:55:38 PM
He probably could, I'll make a thread and mention him in it in case he's interested but for now I can't do anymore work on it because I wrote it on my phone.

Also good luck keoni, I can't think of a way to encode the data for the keys and doors so hopefully you can.
Title: Re: Random dungeon generation
Post by: Snektron on August 23, 2015, 08:54:48 PM
So since we're talking about random generation anyway... A perlin noise function (and a world generated with that) on calc would be awesome O.O
Title: Re: Random dungeon generation
Post by: 123outerme on August 29, 2015, 06:55:25 PM
Oh wow! A random dungeon generation would be possible, my only concern is that the list variable would get pretty large. I'll look at this more later.
Title: Re: Random dungeon generation
Post by: Dream of Omnimaga on August 29, 2015, 07:51:47 PM
What if the only randomly generated thing was the connection between rectangular rooms like the ones in FF and Solius?
Title: Re: Random dungeon generation
Post by: CKH4 on August 29, 2015, 08:11:52 PM
Well @123outerme the list could be a linked list or alternate x,y list or the room direction list (by far the smallest, up to half the size) so at least theres options. The other problem would be door position. It could be random each time or you could set it so that a saved room would generate the same doors if the room matches your own random function calculated by some aspect of the room. You could also have everything open and generate enemies to act as doors but this would either be random or your own random function. Hopefully you'll get the gist of what I'm saying. Also you should be able to see the code soon (I typed it wrong from my phone the other day).


Edit. Just to let you know the code is blatantly simple, it just draws and erases the walls that have another room next to them. (its probable like < 400b)
Title: Re: Random dungeon generation
Post by: Dream of Omnimaga on August 30, 2015, 07:24:11 AM
Oh right, you have it so that two rooms that aren't connected cannot be next to each others. In FF:MF doing this was possible due to the way map data was stored, but it made it hard to draw maps and editing maps was much harder. It allowed maps to be more compact, though.
Title: Re: Random dungeon generation
Post by: CKH4 on August 30, 2015, 01:31:39 PM
Yeah but my preference for a game like this is that it's generated once at the beginning of each game and so editing wouldn't matter.
Title: Re: Random dungeon generation
Post by: Dream of Omnimaga on August 30, 2015, 07:40:26 PM
Yeah true. It's just the map data that would be harder to work with (eg in FF:MF there are many and/or commands in If instructions)