HELP NEEDED: Generation Algorithms

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
CrazyCallum113
Prole
Posts: 2
Joined: Tue Jan 08, 2013 9:50 pm

HELP NEEDED: Generation Algorithms

Post 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
User avatar
micha
Inner party member
Posts: 1083
Joined: Wed Sep 26, 2012 5:13 pm

Re: HELP NEEDED: Generation Algorithms

Post 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).
User avatar
Inny
Party member
Posts: 652
Joined: Fri Jan 30, 2009 3:41 am
Location: New York

Re: HELP NEEDED: Generation Algorithms

Post by Inny »

Rogue Basin is a great resource for roguelike games. You can find a lot of information there on procedural code.
User avatar
Codex
Party member
Posts: 106
Joined: Tue Mar 06, 2012 6:49 am

Re: HELP NEEDED: Generation Algorithms

Post by Codex »

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 0 guests