Difference between revisions of "Resource Algorithm"From Globulation2
Latest revision as of 01:27, 2 October 2009Every tick, the function Map::growRessources() is called, which iterates over the board growing resources. The algorithm is: Along the X axis of the map, examine every 4th row, starting at a random row between 0 and 3. For each examined row, start at a random square between 0 and 15, then move right by a random number between 0 and 31 squares until you reach the end of the row. If there is no resource there, do nothing. Else, look at a square rand(15) - rand(15) squares to the right, and rand(15) - rand(15) down. In other words, binomially distributed around the current square. We'll refer to that as point 1. Also, look at the square twice as far away in the same direction (point 2). Also, look at the square the same distance in the other direction (point -1).
If the current size of the resource is less than or equal to rand(7), the resource grows by one square. Else, if the resource is capable of extending, it attempts to extend into a random square next to the current one (and does nothing if it fails) | ||||||||||||||||||||||||||||||||||