Saturday, February 18, 2006

Generating Worlds

Here's my world generation as it stands, very rough and ready.

 public void Start()



            Seed(25); // Should be a tile percentage

            int growthAmount = 11;


            for (int i = 0 ; i < growthAmount; i++)







            regions.landmasses = detector.DetectRegions(map, TerrainType.Plains);





            regions.coasts = detector.DetectRegions(map, TerrainType.Coast);


            detector.DefineHills(map, averagePlainHeight);

            regions.hills = detector.DetectRegions(map, TerrainType.Hill);


            detector.DefineMountains(map, averagePlainHeight);

            regions.mountains = detector.DetectRegions(map, TerrainType.Mountain);



            GrowTerrain(TerrainType.Forest, forestSeedChance);

            GrowTerrain(TerrainType.Forest, forestSeedChance);


            regions.forests = detector.DetectRegions(map, TerrainType.Forest);


            SeedSwamps(); // just a few.

            regions.swamps = detector.DetectRegions(map, TerrainType.Swamp);



            // The poles.


            Point northPole = new Point(width / 2, (height / 4));

            Point southPole = new Point(width / 2, ((height / 4) * 3));


            map[northPole.X, northPole.Y].Type = TerrainType.Ice;

            map[southPole.X, southPole.Y].Type = TerrainType.Ice;



I need to add rivers and then markers for cities. Also I really wanted to refactor a lot of this using the strategy pattern but I'm not really sure it fits so I'm leaving it.

Potentially my worlds may have lots of features but not all features are necessarily shared between all worlds or generated by each world in the same way. Lava and meadows may not occur on the same world for instance. Forests generation may require knowledge of where rivers are.

Washu post over here looks interesting, I'm looking forward to see the answer.

No comments: