Well, you don’t necessarily have to understand how logarithms work specifically in order to do something with them. Just understanding what you can expect the results to be is enough. For instance, try running this piece of code:
local iterations = 10 for i = 1, iterations do print("math.log("..i..") = "..math.log(i)) end -- console output: -- 20:14:13.101 math.log(1) = 0 -- 20:14:13.101 math.log(2) = 0.69314718055995 -- 20:14:13.101 math.log(3) = 1.0986122886681 -- 20:14:13.101 math.log(4) = 1.3862943611199 -- 20:14:13.101 math.log(5) = 1.6094379124341 -- 20:14:13.101 math.log(6) = 1.7917594692281 -- 20:14:13.101 math.log(7) = 1.9459101490553 -- 20:14:13.101 math.log(8) = 2.0794415416798 -- 20:14:13.101 math.log(9) = 2.1972245773362 -- 20:14:13.101 math.log(10) = 2.302585092994
You’ll see that logarithm of 1 is 0, but for any other positive number you receive a value that has at least 12 decimals (in those first 10 runs, at least). You’ll also see that the first number, i.e. the integer, doesn’t actually change all that much, but the numbers after the decimal do. This is where you can pick out those numbers using the code that I demonstrated above and you’ll receive a nice random seed between levels, while also guaranteeing that each n level will remain consistent should the player re-enter them.
Please do share your code, so that I (as well as others on the forum) can pitch in and help you work some of your problems out.
Now, without having seen your code, I could already imagine some simple tricks for determining that room count. For instance, if you take my previous code trick and generate the table g , you could then write a rule for g[1] stating that “if g[1] < 2 then” there are 5 rooms, g[1] < 4 would create 6 rooms, etc. since you know that each entry of g can have an integer value between 0 and 9. You could then use the other entries of g to determine how the rooms are connected to each other, say, if g[2] is divisible by 2, then there is a door to the right of the starting room, etc.
While I do mention logarithms in my examples, there are countless methods that you can use to approach creating number sequences. The only thing that you need to keep in mind is that if you want to ensure that when the player, for instance, enters floor X that all of the rooms on the floor remain the same should the player revisit them, then you have to use a random seed for your floor that is based on a constant, like the floor number in your case.