Lazy Flood Fill | Procedural Generation | Game Development Tutorial

  Рет қаралды 11,298

White Box Dev

White Box Dev

Күн бұрын

In this video, I explain what lazy flood fill is, how it works, and how to implement it.
0:00 Introduction
0:11 What is lazy flood fill
1:13 How does it work?
6:52 Implementation
9:06 Demo
🔗 Demo:
whiteboxdev.github.io/bundles...
🔗 Source:
github.com/whiteboxdev/exampl...
🎬 Game Development Tutorial Playlist:
• Game Development Tutorial
#gamedev #tutorial #defold

Пікірлер: 25
@PolarTop6260
@PolarTop6260 9 ай бұрын
bro this channel is so underated, this channel teaches you procedural generation methods you might of never heard of, that are simple to understand and looks very good, and also teaches you how to implement them
@juliendev2191
@juliendev2191 3 жыл бұрын
Im not sure lazy is a proper description but it works :) great video !
@icewizzard
@icewizzard 2 жыл бұрын
Just wanted to thank you for the video, really good and I'm using it in my project. First I set some interconnected nodes on the map. Then I colored an area around each of them to be the "safe zone", to make sure each node had its own minimum area. Next I used this algorithm to fill around each node, only adding neighbors that are already the right color or white(empty). This way, they don't "trample" over the safe areas. Finally, I check each node again for its neighbors. If at least one of the neighbors is from one the connected colors, I draw a green border between them. Otherwise, it is black. This gives me a map of countries, each with their own land and borders. Black borders are impassable terrain and green borders are passable.
@romeo9015
@romeo9015 3 ай бұрын
You are my FAVORITE KZfaqr rn. I’ve been playing pygame recently and your videos have been instrumental for visualizations.
@Sketchaphone
@Sketchaphone 8 ай бұрын
what a simple yet effective tweak to generate landmasses. I was looking for different techniques for generating terrain and I'm delighted to see that a modified floodfill does the trick
@AntsanParcher
@AntsanParcher Жыл бұрын
A few changes I'd propose: 1. Have the chance variable be local to every tile on the deque. Reduce it only for the neighbors you push onto the deque. Implement it by pushing (tile, chance) tuples onto the deque. This makes the decay factor less sensitive. 2. Don't roll for pushing all neighbors onto the grid, but roll for whether to fill the current tile and recurse afterwards. As it is, the border of the filled region is made up of little crosses, which is kinda visible in the final result. Not sure whether it makes some border shapes actually impossible.
@R.B.
@R.B. 5 ай бұрын
That was going to be my recommendation. I think the chance should be localized and maybe even influenced by the neighbors which have been visited. It might also be interesting if the chance were influenced by how many tiles of a biome were already laid, so that decay wasn't what governed the decision only and therfore you could keep the sizes as a constraint. It would also be an enhancement if the fill of multiple biomes were pushed to the stack to seed them all at once so that you didn't have overlapping zones, more like loosely defined voronoi. The stack would need to be able to search for existing tiles already queued, but then it would maybe give you more zones.
@JohnMcChungus
@JohnMcChungus 3 жыл бұрын
I love these videos, you're giving me a lot of neat ideas about alternative methods for world generation :)
@davdav4804
@davdav4804 Жыл бұрын
Thanks man, your video is a blessing, I really look forward to try to implement this in my projects ! Thank you so much for sharing and explaining it so well because I work with Unity and I already have a vague idea of how I will try to implement it!
@ABHISHEKSINGH-nv1se
@ABHISHEKSINGH-nv1se 3 жыл бұрын
Simple graphics and algorithmic problem, This is what i like most. And that is why i like your videos. 😃
@awesomegamedev
@awesomegamedev 2 жыл бұрын
Nice! Take 100th like:) I am surprised though, that you multiply chance by decay every single time, instead of only multiplying it when adding neighbors: deque.push_back() This would make the algorithm more symmetric (instead of biased towards the direction which you check first, and which correspondingly has the highest chance) and the value of change&decay have a more meaningful value.
@Smarceloz
@Smarceloz 2 жыл бұрын
Thank you for this. I was with my game development stopped, because I wasn't finding a solution to generate biomes on my map.
@disdis6127
@disdis6127 3 жыл бұрын
Great video
@Gandalf_Le_Dev
@Gandalf_Le_Dev 3 жыл бұрын
Very nice tutorials I love them ! Could you tell us your approach to save procedurally generated maps ?
@WhiteBoxDev
@WhiteBoxDev 3 жыл бұрын
No need to save them. The only thing you need to save is the seed used for the random number generator. To reproduce the same map, plug in its seed. If the world is changed for some reason (player interacting with the world), then the changed areas should be saved and reapplied when loading the map.
@hamsterbyte
@hamsterbyte 10 ай бұрын
Very interesting algo. I'm curious though, did you try any aside from exponential decay? Perhaps logarithmic, linear, or quadratic? I'm not suggesting there is anything wrong with this implementation as it is really quite clever, I'm really more interested in how the decay would fall off if it were implemented with another algo. Gonna throw you a sub for getting me thinking. Great job.
@SyntekkTeam
@SyntekkTeam 3 жыл бұрын
Nice video! I'm curious, in your game how would you use the black areas that are left open by the algorithm? I'd like to have my space to be completely filled, so my default is voronoi, but I like how organic yours looks, so I'm wondering if there's a way to combine both My initial thought is to execute multiple flood fills from random positions, where they each take turns stepping through the algorithm. To make it organic, flood fill would have to randomly select between the neighbors somehow (possibly biasing the select to neighbours closest to the fill origin? I'm not sure)
@WhiteBoxDev
@WhiteBoxDev 3 жыл бұрын
In my mind, the black areas should be interpreted as flood filled areas as well. For example: if you use blue, red, and green in your flood fill which represent "ocean", "desert", and "forest" respectively, then the leftover black could be thought of as "plains" or some other type of biome. You could also do a scan of the map and perform more flood fills in the areas where black is detected until there is no black leftover. Just a few thoughts.
@disdis6127
@disdis6127 3 жыл бұрын
Btw please make a video on A* pathfinding algorithm.
@bike_n_fish
@bike_n_fish Жыл бұрын
Every time I discover a knew procedural generation algorithme I'm like a child before christmass wondering what stupid things I will do with my new toy
@WhiteBoxDev
@WhiteBoxDev Жыл бұрын
The cool thing about procgen is that you can create your own quirky algorithms just by thinking of little tweaks that might align better with whatever you're making. There are many established algorithms, but what makes them really come to life are the little changes you make.
@homelessdorito2263
@homelessdorito2263 Жыл бұрын
What did you do in your demo to get the generation to have more irregular shapes rather than tend towards circles? More irregular shapes would be ideal for my project
@WhiteBoxDev
@WhiteBoxDev Жыл бұрын
The implementation I explained in the video is exactly what I wrote in the demo project.
@homelessdorito2263
@homelessdorito2263 Жыл бұрын
@@WhiteBoxDev Thank you for the quick response! I am certain that I implemented it correctly; I suspect it might be due to a difference in math.random implementation in the engine i'm using. Looks like i'll need to find a different generation method
@lastvirtualdomain
@lastvirtualdomain 6 ай бұрын
im doing something wrong, the edges are great... but at large scales.. it looks mostly square.
Fractal Noise | Procedural Generation | Game Development Tutorial
19:35
How does procedural generation work? | Bitwise
13:48
DigiDigger
Рет қаралды 381 М.
50 YouTubers Fight For $1,000,000
41:27
MrBeast
Рет қаралды 189 МЛН
What it feels like cleaning up after a toddler.
00:40
Daniel LaBelle
Рет қаралды 73 МЛН
路飞被小孩吓到了#海贼王#路飞
00:41
路飞与唐舞桐
Рет қаралды 80 МЛН
Русалка
01:00
История одного вокалиста
Рет қаралды 7 МЛН
Giving Personality to Procedural Animations using Math
15:30
t3ssel8r
Рет қаралды 2,5 МЛН
Defold For Unity Developers
19:40
Gamefromscratch
Рет қаралды 42 М.
Simulating the Evolution of Rock, Paper, Scissors
15:00
Primer
Рет қаралды 1,1 МЛН
Diamond Square | Procedural Generation | Game Development Tutorial
15:55
Dear Game Developers, Stop Messing This Up!
22:19
Jonas Tyroller
Рет қаралды 696 М.
A new way to generate worlds (stitched WFC)
10:51
Watt Designs
Рет қаралды 518 М.
Programming a multiplayer game from scratch in 7 DAYS
18:28
Cellular Automata | Procedural Generation | Game Development Tutorial
15:22
Brian Bucklew - Dungeon Generation via Wave Function Collapse
26:32
Roguelike Celebration
Рет қаралды 42 М.
iPhone socket cleaning #Fixit
0:30
Tamar DB (mt)
Рет қаралды 15 МЛН
Я купил первый в своей жизни VR! 🤯
1:00
Лазер против камеры смартфона
1:01
NEWTONLABS
Рет қаралды 563 М.
Xiaomi SU-7 Max 2024 - Самый быстрый мобильник
32:11
Клубный сервис
Рет қаралды 340 М.