Page 1 of 1

HELP NEEDED: Generation Algorithms

Posted: Tue Jan 08, 2013 10:00 pm
by CrazyCallum113
Me and a friend have recently started a game which is developed in the Love2D engine (of course) and we want to make a somewhat rouge like game where every room you progress through is random so every play through is different, think of it like binding of isaac.

The problem is, we don't have any idea on algorithms at this current moment in time. We are using a tile based map system were there is 7 different tile textures which that tile could be (0-6).

Code: Select all


-- tiles
-- 0=black, 1=cobblegrnd, 2=dirtgrnd, 3=woodgrnd
-- 4=cobblewall, 5=dirtwall, 6=woodwall

--example map
map={
    {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
    {0,0,6,6,6,6,6,6,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
    {0,0,6,3,3,3,3,6,0,0,0,0,0,4,4,4,4,4,6,6,6,6,0,0,0,0,0,0,0,0},
    {0,0,6,3,3,3,3,6,4,4,4,4,4,4,1,1,1,1,3,3,3,6,6,6,6,0,0,0,0,0},
    {0,0,6,3,3,3,3,3,1,1,1,1,1,1,1,4,1,4,6,3,3,3,3,3,6,0,0,0,0,0},
    {0,0,6,6,3,6,6,6,4,4,1,4,4,4,1,1,1,4,6,3,3,3,3,3,6,0,0,0,0,0},
    {0,0,0,5,2,5,5,0,0,4,1,4,0,4,4,1,4,4,6,6,6,6,6,6,6,0,0,0,0,0},
    {0,0,0,5,2,2,5,0,0,4,1,4,0,0,4,1,4,0,0,0,0,0,0,0,0,0,0,0,0,0},
    {0,0,0,5,5,2,5,5,5,4,1,4,4,0,4,1,4,5,5,5,5,5,5,5,5,5,5,0,0,0},
    {0,0,0,0,5,2,2,2,2,1,1,1,4,4,4,1,1,2,2,2,5,5,2,2,2,2,5,0,0,0},
    {0,0,0,0,5,2,5,5,5,4,4,1,1,4,4,1,4,5,5,2,2,2,2,5,5,2,5,0,0,0},
    {0,0,0,0,5,2,5,5,0,0,4,4,1,1,1,1,4,0,5,5,5,5,2,5,5,2,5,0,0,0},
    {0,0,0,0,5,2,2,5,0,0,0,4,4,4,1,4,4,0,0,0,6,6,3,6,6,3,6,0,0,0},
    {0,0,0,0,5,5,2,5,5,0,0,0,0,4,1,4,0,0,0,6,6,3,3,3,3,3,6,0,0,0},
    {0,0,0,0,0,5,2,2,5,0,0,0,6,6,3,6,6,6,6,6,3,3,3,3,3,3,6,0,0,0},
    {0,0,0,0,0,5,5,2,5,5,5,5,6,3,3,3,3,3,3,3,3,3,3,3,3,3,6,0,0,0},
    {0,0,0,0,0,0,5,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,3,3,3,3,6,0,0,0},
    {0,0,0,0,0,0,5,5,5,5,5,5,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,0,0,0},
    {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
    {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
}

That code shows an example of what it could look like, obviously it cannot just be randomly generated for random tiles to be dotted everywhere it actually needs to form a basis of a room. I have no idea how I would do this at all so I was hoping for some advice. If you need further information to how the map system works feel free to ask :)

Thanks in advance everyone :D

Re: HELP NEEDED: Generation Algorithms

Posted: Tue Jan 08, 2013 10:42 pm
by micha
To my knowledge this kind of level generation can get as complex as you want. This technique by the way is called procedural generation: http://en.wikipedia.org/wiki/Procedural_generation

Here is one solution suggestion: Instead of choosing each tile at random, prepare some squares of, say, 10 by 10 tiles and combine these randomly.
For example one 10x10 block can contain a room with four exits. One block can contain some columns and a chest, and so on. Just make sure that it is always possible to reach all areas (don't put too many walls).

Re: HELP NEEDED: Generation Algorithms

Posted: Wed Jan 09, 2013 12:01 am
by Inny
Rogue Basin is a great resource for roguelike games. You can find a lot of information there on procedural code.

Re: HELP NEEDED: Generation Algorithms

Posted: Wed Jan 09, 2013 2:46 am
by Codex