Ideally, you would have each different “biome” represented with an int, that represents its index. So a forest would be 0, a desert would be 1, water would be 2, etc.
Then, you would have an array (in your case 8x8, so with 64 elements), and you just add the corresponding index the amount of times you need. So, if you want a mountain at least 6 times, you add the index corresponding to the mountain (let’s assume that index is 4) 6 times to the array. Then you do that for all the tiles you want at least a certain amount of times in your world.
When you’ve added all the amounts you want, but your array is still not full with 64 elements, simply add biome indexes at random until your array has 64 elements.
When you’re spawning your biomes, pick a random index from your 64-size array, use it to spawn a biome, and remove it from the array. That way, you’ll have the amount of biomes you want, but still randomized.
I have created an array (currently 8x8) in order to make a 64 cube grid. The idea of the grid is to be a map for players to combat on. So I am looking to make the map randomly generated. I have created several blueprint tiles, mountain, Forest, Water, ETC and I have placed them in to the map and they are placed randomly on construction and it works to a degree.
My issue is I would like to set a minimum and maximum amount of water tiles, a min, max amount of mountain tiles and so on. So that the map always has the same ingredients just in different locations. (for game balancing purposes)
At the moment my logic is overwriting previously set elements, so it looks through and makes say 8 index elements a 1 and 1 corresponds with water, but then I loop through and grab random index and set their element to 2 to create mountains. However as the whole thing is random there are times that the, let’s say water tiles, that were previously set are being overwritten by the new mountain loop.
So does anyone know any basic logic to create an array with randomly filled indices but with a specific number of specific Elements?