Sunday 31 October 2021

Forest update

Previously I had a class called "Area" to create almost anything from regular caverns to forests, but it was simply too generic, because the generation was tied to a cavern. I created a new class Forest that is only creating forests. It has a new type of generation logic based on flood fill which I think works better than just placing trees in a roughly circular area.

It's quite important to avoid generic routines, because they will become too complicated and for some features may not even work in the end. However the parts should be mostly reusable, like in this context the flood fill routine itself will be reused in other routines that require filling an area.

Since cavern routine was also using the flood fill which was kind of weirdly modified flood fill it no longer works. This is why you should plan "low level" routines so that they wont break, but offer a true generic way to do something right from the beginning. The division to specific and generic is the main problem in roguelike projects I think, and probably in most projects ever.

I think a modified flood fill should be ok for a cavern routine, because that's what you want. You want to fill an area but not make it a perfect linear fill, but deviate it to generate irregular shape which still detects the proximity of other features like rooms etc. The proximity value will be a great way to create something like lakes inside a cavern.