Wednesday, April 9, 2014

HigherPower - Oh, Right

While in the car today, a realization struck me concerning HigherPower's increased world generation time. (In the middle of all the crazy busyness going on in my life right now, I don't have time to actually write about important things here.)

A configuration file option tells the HigherPower world generators how many ores of each type to place in each chunk. If I remember correctly, 200 Fleexium and 2 Eethur ores are generated per chunk. It doesn't take a lot of time to pick 200 random locations and try to put an ore block there - but what does take a lot of time is continuing the pick random locations until 200 blocks are filled with ore. This takes even longer for Eethur, which has extremely specific spawning conditions.

Now I feel somewhat silly. Instead of trying to generate a maximum of 200 ores per chunk, I'm forcing it to place all 200 somewhere. With the 1.7 world generator bringing a lot more variety in the underground block types, this resulted in a huge slowdown for HigherPower, which only places its ores in regular stone. I suppose I'll soon be changing the code to use a maximum of some higher number.

Mental program optimization! Gedankenexperiments!

No comments:

Post a Comment