wrote an essay on terrain generation, the math behind it, with some code to generate it. The algorithm is useful in games like Counter-Strike, Age of Empires, etc, to programmatically generate terrains.
Interestingly, all it takes is a bunch of cosine functions layered on top of each other. Give it a read - it’s pretty interesting.
By the way, I originally wrote this in 2020, but I thought I’d share it again since it’s been more than five years :)