Being a programmer of sorts, the gears and such behind the visible surface of a program has always intrigued/interested me. As a result, I started looking around for anything I could find on how Terraria maps are generated. For example: Does it place the caves first and the ores around them, does it place the ores first and wipe them out with the caves, does it place the chests before or after everything else, how does it place the dirt/stone, what mathematical formulas place the different materials, what determines how many chests there are on a particular map and what is the average count; basically anything and everything.

I ran a search on Google. "Terraria Map Generation". Only one hit, and not what I was looking for, either. After that, "Terraria Terrain Generation". Again, nothing satisfactory - only two hits, and neither relevant. Of course, this forces me to wonder: Is there a reason there's no data on the subject? Does nobody really know how it works? Or is it possible I'm looking in the wrong places or asking the wrong questions? I'm simply a curious guy wanting to know a little bit more about the inner workings of what has quickly become one of my favorite games.