Exemplo n.º 1
0
        /// <summary>
        /// Erodes plates.
        /// </summary>
        private static void GenerateErosion()
        {
            var rulesLocation      = InputFileName("Erosion Rule");
            var inHeightLocation   = InputFileName("Height Data");
            var inRainLocation     = InputFileName("Rainfall Data");
            var outErosionLocation = InputFileName("Erosion Data");
            var outIsWaterLocation = InputFileName("Is Water Data");
            var rules       = (ErosionMapRules)RulesIO.Load(rulesLocation.Name, nameof(ErosionMapRules));
            var heightMap   = PointIO.OpenDoubleData(inHeightLocation.Name + ".bin", 2 * rules.xHalfSize, rules.ySize);
            var rainfallMap = new double[2 * rules.xHalfSize, rules.ySize];

            for (int i = 0; i < rules.numberSeasons; i++)
            {
                var rainfallMapTemp = PointIO.OpenDoubleData(inHeightLocation.Name + ".bin", 2 * rules.xHalfSize, rules.ySize);
                for (int x = 0; x < 2 * rules.xHalfSize; x++)
                {
                    for (int y = 0; y < rules.ySize; y++)
                    {
                        rainfallMap[x, y] += rainfallMapTemp[x, y];
                    }
                }
            }
            GenerateErosionMap.Run(heightMap, rainfallMap, rules, out bool[,] isWater, out double[,] erosionMap);
            PointIO.SaveHeightImage(outErosionLocation.Name, erosionMap);
            PointIO.SaveMapData(outErosionLocation.Name + ".bin", erosionMap);
            CheapBinaryIO.WriteBinary(outIsWaterLocation.Name + ".bin", isWater);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Saves point data to the given file.
        /// </summary>
        /// <param name="fileName">File to open.</param>
        /// <param name="rules">Rules for how data will be written.</param>
        /// <param name="pointData">Data to save.</param>
        public static void SavePointData(string fileName, GeneralRules rules, PlatePoint[,] pointData)
        {
            var plateNumbers       = new int[2 * rules.xHalfSize, rules.ySize];
            var xBirthPlace        = new int[2 * rules.xHalfSize, rules.ySize];
            var yBirthPlace        = new int[2 * rules.xHalfSize, rules.ySize];
            var birthDate          = new int[2 * rules.xHalfSize, rules.ySize];
            var isContinental      = new bool[2 * rules.xHalfSize, rules.ySize];
            var continentalBuildup = new int[2 * rules.xHalfSize, rules.ySize];
            var continentalRecency = new int[2 * rules.xHalfSize, rules.ySize];
            var oceanicBuildup     = new int[2 * rules.xHalfSize, rules.ySize];
            var oceanicRecency     = new int[2 * rules.xHalfSize, rules.ySize];

            for (int x = 0; x < 2 * rules.xHalfSize; x++)
            {
                for (int y = 0; y < rules.ySize; y++)
                {
                    plateNumbers[x, y]       = pointData[x, y].PlateNumber;
                    xBirthPlace[x, y]        = pointData[x, y]._birthPlace.X;
                    yBirthPlace[x, y]        = pointData[x, y]._birthPlace.Y;
                    birthDate[x, y]          = pointData[x, y]._birthDate;
                    isContinental[x, y]      = pointData[x, y].IsContinental;
                    continentalBuildup[x, y] = pointData[x, y].History.ContinentalBuildup;
                    continentalRecency[x, y] = pointData[x, y].History.ContinentalRecency;
                    oceanicBuildup[x, y]     = pointData[x, y].History.OceanicBuildup;
                    oceanicRecency[x, y]     = pointData[x, y].History.OceanicRecency;
                }
            }
            CheapBinaryIO.Write(fileName + plateNumberExtension, plateNumbers, rules.plateCount);
            CheapBinaryIO.Write(fileName + xBirthPlaceExtension, xBirthPlace, 2 * rules.xHalfSize);
            CheapBinaryIO.Write(fileName + yBirthPlaceExtension, yBirthPlace, rules.ySize);
            CheapBinaryIO.Write(fileName + birthTimeExtension, birthDate, rules.ySize);
            CheapBinaryIO.WriteBinary(fileName + isContinentalExtension, isContinental);
            CheapBinaryIO.Write(fileName + continentalBuildupExtension, continentalBuildup, rules.maxBuildup);
            CheapBinaryIO.Write(fileName + continentalRecencyExtension, continentalRecency, rules.currentTime);
            CheapBinaryIO.Write(fileName + oceanicBuildupExtension, oceanicBuildup, rules.maxBuildup);
            CheapBinaryIO.Write(fileName + oceanicRecencyExtension, oceanicRecency, rules.currentTime);
        }