A Randomly Generated World

Okay, this is a big flowlab question. Recently @meburningslime has discovered a way to randomly generate something, which is very intriging. It got me questioning if there was a way to generate a random world with… “Advanced” settings or user control in a top down game. So, Imagine if when the world is generated, there are large patches of grass or stone or something else of your choice, coded so they would be bunched to gether rather than a mosaic or random tiles. Then if you wan to advance it further, you could have things like lakes or lava generated on certian tiles. And then, probably another hard bit, have structures generated on this world. A structure made of many different blocks and tiles, but coded so when next to a certian different block it would have to go or “spawn” to somewhere specifically near it.

My next point is spawing. If something needs to generate a certian point or co-ordinate, spawing is most likely our most powerful asset. As well as Extractors, attacher, Raycast, position, as well as finally expressions. Combined, these can help the customisation of the genrated world. Recently @“JR 01” Made a game of 1 object (Crazy, i know) and so maybe this code can be a crucial key to solving this. This world generation with customisation is also featured in Terraria, minecraft and Don’t Starve, which portray different types of generation. Obviously don’t starve is the best example because it is 2d and top down. So how would thios be tackled, in a more watered down breakdown summery of some experienced flowlabbers like @grazer , the creator (Love to see your input on this) @“JR 01” @PixelPizza @meburningslime @todorrobot @TinkerSmith

This is the game I am using for an example of this that I have not done anything with whatsoever is this (Literally has no code):

I have made a suggestion (in this discussion) for a new behavior that I believe would be helpful in making a randomly generated landscape/structure called the “structure” behavior. People have said that, while a structure behavior would seem like a good idea, it might cause lag. And then immediately afterwards, it got buried and I forgot all about it.
If such behavior were to be added, that would be AMAZING, and it would help out a lot with certain games I am making. Pixel Sports Dungeons would have randomly generated levels whenever someone plays starts a new game instance, so you wouldn’t always have to deal with the same level all the time. Stealthy Ninja would have randomly generated rooms that would have certain rooms filled with enemies, keys, etc.

Hmmm @Superstargames , interesting idea.

So would that be like an object group?
Would it act as one big object (like a mega boss), or as a level?
Also, can be assigned to different display levels?
Indeed, interesting idea.

I personally think what would help in @“The Kodex” request would be arrays, lists, tables, or whatever you like to call them.
Map generation is easy … .if you have an easy way to store and process the data.

Here is an example where someone used the Perlin Noise I mentioned in that other thread:

There are others, but all are easier to implement when you can use lists (lets call them that for now). The other thing would be the quite limited equation block, one would have to tie multiple together because of the 2 parameter limit.
@grazer , would it somehow be possible to access the Global Variables from within the equation blocks? That would bypass this limitation :slight_smile:

OR … script block … Yumm Yumm (I smell disaster, LOL)

P.S. one other thing that would be handy for this is a seeded random generator.
It would allow to create the same map with the same seed

Hi, I actually recently worked on a random Dungeon Generator! However, I can’t show the final results yet.
Here’s a gif that “shows” the logic behind it:

@TinkerSmith you can access Global variables from the Expression blocks if you connect the Global output to the “B” input of the Expression. :slight_smile:

1 Like

@PixelPizza That does look quite interesting as it could be helpful but I think it would need to be taken to a larger scale. Imagine if it done that in a neater, more Controlled way, for around 40-45 blocks wide, that would be a biome.

Imagine you do what I said above for grass, and then another for stone and dirt and ect, and the “generator” randomly spawned the blocks that would cause these “Biome Creators”, that could easily be the start of this. The only problem is making sure they don’t overlap too much with other biomes, which is easy and some if you code the “Biome Creators” to destroy or not create biome If touching grass, or whatever the other biome is made from. But this is still risky and may not be accurate.

That is what the STRUCTURE block, an idea by @Superstargames could come in handy. It could help make controlled biome creators with more customisationable options. So the structure code combined with @PixelPizza EXTENDED (As I explained above) Biome Creator Code we could have the beghining of this.

Only 1 romaining problem. Only this time, @grazer can help Mostly*. The fact that the structure block does not exist yet is… More or less a problem. A massive one. So its really up to grazer if he decides to make the Structure block happen.


*What if we attempted to make our own structure block? We have a bundle with inputs and outputs, and we extract some of the code from @PixelPizza s example as well as @“JR 01” s “1” game,and actually attempt to make something that does a similar job to the structure block. If this were to happen, we could complete the formula I invented above to create the Ultimate Biome Creator, Structure block, Dungeon Gererator or… The Generator Code block to finally make this into a reality

Now I am good with flowlab, 1 year and a few months experience, but I’m not that good. Now… I just need people like @PixelPizza @grazer @“JR 01” @todorrobot @TinkerSmith and @Superstargames (He did come up with the Structure block Idea after all) To help us develop this. Anyone willing to lend a hand? Just some suggestions, Ideas, screenshot of code, anything to help no matter how big nor small to Contribute towards this.

Thanks for helping!

Nice one @PixelPizza , is that a simplified binary tree algorithm?

Lol, sure I know that I can feed the globals into the equation block, but that still leaves me with 2 inputs and you have to chain them if you need more.
What I mean is to be able to use Globals by name in the equation field.
Like: A+B*Global1+Global2 etc.

I have to dig, somewhere I have a binary generator that works top down, row by row. I show you when I find it :slight_smile:

@TinkerSmith Any thoughts on what I posted above?

Yes @“TinkerSmith” and @“The Kodex”, you COULD make a structure behavior yourself using bundles, but that would be MUCH more complex than if it was it’s own independent behavior. I would personally prefer a structure behavior to a structure bundle.

But I’ll see if I can make such bundle.

Am I late to the party? lol
This is very well possible, its just depending on how you want the game generated.

If its like that example that Pizza just showed, then you would up scale it to have the sizes of the rooms, with a separate room generator to make them. What would also be better is to use pre-made (spawn) sets for the rooms so the rooms aren’t completely random (or unplayable). Also a sequence to know what room and orientation the room is at (for is you want the last room to be the boss room).

But if it’s open world like Teterria, You need to first define the air and landscape (maybe to what slime showed before). Then need a separate generator for whats in the sky, whats on the ground, and whats underground. then you make separate generators for those.

I personally like the idea of using pre-set (spawns) to make the random area instead of trusting on full randomness (aka like how Minecraft has random floating pieces of ground). I had a few ideas before, but never actually gave full time, nor attention, to those ideas (plus its a lot of additional work).

So I have made an example game of a randomly generated structure (and terrain, but I am not talking about that since it looks awkward and only spawns in pillars of ground). It took me just 30 minutes to work out all of the settings I need to use for the structure bundle.
Flowlab Game Creator - Random Level Generator (2D) - Google Chrome 6_4_2020 3_10_06 PM
So I think this bundle would work great, but I still think it should be it’s own independent behavior rather than a bundle that people have to make from scratch.
If you want the import code, I’ll gladly give it to you, but it is so long, that it won’t be allowed to be posted on this comment.

@“The Kodex” , @Superstargames , I have to admit I’m still trying to wrap my head around the ‘structure’ concept. I guess everyone has a different way of looking at it … and my head overly complicates it in my mind LOL :slight_smile:

Could you maybe make a visual mock-up to explain? When my coffee levels are low I need visuals :pensive:

@“JR 01” I agree that somehow the result has to be predictable. That’s why I mentioned the seeded random generator, that would be another way of making sure the result ‘fits’. The developer could seed levels during the design process and would just need to keep the ‘good’ ones. That with a combination of pre-made spawns as you mention would even be better.

Why I hesitate to save complete level spawns? Old habbit, save memory where you can, LOL, I know, not necessary nowadays. But pre-seeded levels could be huge. Also, if it is seeded you could extend the map ‘on the go’ and still would have predictable results. That way your world could be (nearly) endless.

And memory wise … I love to play on my android phone, but have to say that somehow every Flowlab App I loaded at some stage crashed it (memory leaks, @grazer ?). Ok, it’s an old Android 5, but also happens on 9.

whispers … i need tables … :wink:

Yes, everyone has a different way of looking at it. It all depends on the game you are making, and what the structure will be for.

@Superstargames I totally agree it should be an independent behaviour BUT the bundle Idea should be used if @grazer decides not to do this great idea - _-

Regarding the Pseudo Numbers I mentioned before, found my old java-fiddle and ‘flowlabed’ it

-> http://flowlabing.wikidot.com/bundles:4

Again, this would allow to create repeatable maps/dungeons/whatever by using the same start seed.
Also, lets say you create a random dungeon/map and the player reaches the end. If you saved the last used seed and use that as a starting point, you can generate the continuation of the dungeon from there :slight_smile:

Hard to explain, do I make sense??? LOL

For example, @PixelPizza could try different seeds to generate his dungeons. Then he can keep the seeds he likes and uses them in the game. Instead of a whole level he would only have to safe ONE value :slight_smile:

Cheers, back to work

P.S. might be buggy, LOL, quickly thrown together during my break. I’ll check it tonight.

Not sure to call it random if its repeatable lol, but is a nice continuous randomizer.
Its a pretty good example of a seed generator. It also gives me a better idea on PRNG.

Arrrrgh … it never works the way it should, LOL

Regarding the map generator, I remembered a version that uses Conway’s ‘Game of Life’ algorithm.
I threw a map together, randomized it (very gentle with warm hands) and now I try to count the neighbors of each cell.

Run the demo and when you click on one cell it ‘should’ show the amount of neighbors on the top … should.
But I get no consistent results, is using raycast the wrong way to do it? Is it not that reliable?
Should I change my hobbies? LOL

Advice please :slight_smile:

Wow, you can make Minesweeper with that @TinkerSmith lol.
Raycasts is good but if you shoot at a corner, it’s possible to hit 2 blocks instead of the corner block you want. If you want to count all the surrounding blocks, then its best to use a proximity. Also use a timer set to 0 (repeat of 1) to be “done” on the next frame (after it finishes calculating).

If your looking for neighbors (not counting corners), try this: (A*90)

If you are counting corners, try this:
Proximity set to “all objects found” and with a delay of 2, and the timer has a delay of 2 and a repeat of 1. Oh yeah, also turn the switch off in the editor.

Lol, yes @“JR 01” , Minesweeper would work. Can’t continue today, day’s over here and I laze in bed with my phone :slight_smile:
I wish I could ‘flowlab’ on my phone, but I only see half of the editor, lol.
About the proximity sensor, actually that was what I used first (dead old Random 1 grin).
My concern … at the moment I test it with the mouse click on a single cell BUT they are all supposed to scan at the same time to evaluate the map…

Can you imagine the lag the proximity sensor would create on this ‘small’ map.
What I would like (pokes @grazer ) would be an ON/OFF switch for the proximity sensor :slight_smile: so that you can use it on demand only.

Basically what I’m doing here is that I abuse the playfield itself as a data array. Since there is no way I can think off to ‘ask’ every single cell one by one …

I have to sleep over it :slight_smile:
Maybe other ideas pop up over night, I hand it over to the other time zones, lol

P.S. @“JR 01” , does raycast target the collision shape?
In that case I could use smaller targets so that there is a gap at the 45 corner.
As said, can’t check atm, just popped up in my mind.