hello,
i was wondering how do game developers usually generate an infinite amount of levels, like you finish a first level and the second one is generated with a slight increase in difficulty.
I am not talking about an endless runner here, i want multiple level generator here, if you can help.
thank you in advance.
The answer is going to be wildly different between different genres, different game rules, what you want the game to do, etc. Random level generation is a very âmade to orderâ sort of thing, and realistically, may end up being most of the work of creating your game, at least if you want the levels to be any good.
If you want some advice on what direction to start, we will need to know a lot more information about your game before we could even begin to give any advice.
As StarManta said, weâd first need to know what genre we are even talking about, what âdifficultyâ is in that specific game, and what changes are allowed to a level and what changes are not. With these informations in mind you can then try to write an algorithm to fit your criteria. For some usecases there may already be algorithms you can use and adjust.
There is probably an infinite amount of ways to approach this problem even with the above information known. Starting with doing mostly random changes (but checking that the level is solvable), to training a neural network to create levels of increasing difficulty (a bit exotic, but possible). Most reasonable solutions are somewhere inbetween and depend on what exactly you want, and how well you can abstract the problem and implement that abstraction.
So there really is no one right answer to your question, especially with how broad the question was formulated.
Google for Spelunky articles for a good case-study. The author of that game wrote a very robust and effective level generator and has been writing articles about the âmaking-ofâ ever since.
Hereâs an example project which might be of interest
The general term for this is procedural (level) generation. Usually you donât technically get an infinite number of possible results, just a very large number.
hello again,
first of all thank you for your answers, ill add some details about the game.
itâs a hyper casual, 3D top down camera runner game. each round is about a certain distance and the player has to avoid obstacles(you can think of it as a temple run but with several 30s-1min levels). I currently generate obstacle randomly on the road by instantiating a random obstacle prefab from a list of prefabs all along the road. i can increase difficulty by reducing the space between each wall as well as increasing the speed of the player or even add prefabs the the list when reaching a certain number of levels.
My aim here and the question i am asking for is:
-is there a way, when the player finishes the 1st level to save the level he did so he can play the same level again, and create a new level with the increased difficulty ?
let me know if it was unclear or if you need more information,
thank you
How do you generate your randomness? If you use a seed for your generator, the same seed should give you the same level if the order you get the numbers are consistent.
As recommended before, read up on the procedureal Level design.
Youâll soon come across what is called âPerlin Noiseâ which is used for much of the random generation stuff. One of the great properties of Unityâs implementation (and many others) is that although the numbers in a sequence vary sufficiently to fulfil random requirements, the always produce the same numbers if you enter the same sequence. So, to randomize your Level, you pick a âseedâ or starting Point, and from there on, all numbers are random from the seedâs perspective, but will always return the same random value in the sequence.
Long Story short: you donât really have to save the Level if you are using such a random Generator, just the seed, and youâll be able to recreate the same Level every time by using the same random sequence.
There are multiple approaches to this possible but the basic idea is common behind all of them. Create blocks of different complexity and combine them to get total complexity of N from M blocks, where N and M increased every K of levels. And if youâre using something line genreated terrain or labyringh then you must denote generation parameters what affects final complexity of level and increment them too.
To save the level, just keep track of where you placed which object and then save that. However, it is kinda weird if different users have different versions of the game, so iâd generate the levels based on a seed. That way you also do not need to save anything, since the same seed will result in the same level again. For the next level, slightly increase one or more of your difficulty settings and generate a new level based on the new values. However, you may eventually run into problems where you create impossible levels, so you will need to check for that.
To be honest tho, it does not seem (to me) like such a game can possibly make a case for âinfiniteâ levels. Either you create levels of very little difficulty increase, in which case it may get boring, or you run into the problem of âimpossible levelsâ rather fast, meaning you could have just manually created the levels.
This may not be the case between different platforms. One needs to make sure he using random generation algorithm wich is stable between platforms if planning to allow cross-platform users to play together.
Well, if the level generation isnât linked to difficulty, it should be a worthwhile approach to level generation. Letâs say you randomize the layout of a village, and then can have an infinite number of different villages etc, so creating an open world exploration game is a candidate as well. Akthough, I general I agree. I yet have to see a good Level-progressed game that entirely relies on procedural Level Generation. The good ones always seem to have some hand-crafted parts to ensure Quality, Balance and fun.
thank you very much, a seed is definitely what i need, i will look into it! as for the progression ill try to balance it and improve it as i go, this is mostly a test the seed process is all i was trying to reproduce. thx a alot for the help and for the linked docs!