示例#1
0
    public void TestYearlyRainfallLayer()
    {
        HumidityLayer testEquation   = new HumidityLayer("HumidityTests", 6, 1);
        string        filePathPrefix = @"C:\Users\William\Documents\World Generator Maps\CavemanWorld\DynamicCavemanWorld\Assets\Resources\CSV\";

        testEquation.readCSVFiles(filePathPrefix);
        DailyLayer       rainfall      = testEquation.GenerateWorldsYearOfRain();
        SingleValueLayer rainfallTotal = new SingleValueLayer("Yearly Rain Total", "Yearly", 1);

        rainfallTotal.worldArray = rainfall.findYearTotalArray();
        int positivecount = 0;
        int excesscount   = 0;

        for (int a = 0; a < 50; a++)
        {
            for (int b = 0; b < 50; b++)
            {
                if (rainfallTotal.worldArray[a, b] >= 0)
                {
                    positivecount++;
                }
                if (rainfallTotal.worldArray[a, b] > 150)
                {
                    excesscount++;
                }
            }
        }

        Assert.AreEqual(50 * 50, rainfallTotal.worldArray.Length);
        Assert.AreEqual(50 * 50, positivecount);
        Assert.AreEqual(0, excesscount);

        Debug.Log(printArray(rainfallTotal.worldArray));
    }
示例#2
0
    public void YearOfRainTest()
    {
        // Test the Storm Generation method
        HumidityLayer testEquation   = new HumidityLayer("HumidityTests", 6, 1);
        string        filePathPrefix = @"C:\Users\William\Documents\World Generator Maps\CavemanWorld\DynamicCavemanWorld\Assets\Resources\CSV\";

        testEquation.readCSVFiles(filePathPrefix);
        DailyLayer rainfall      = testEquation.GenerateWorldsYearOfRain();
        int        zerocount     = 0;
        int        positivecount = 0;

        System.Random randy = new System.Random();
        int           x     = randy.Next(0, 50);
        int           z     = randy.Next(0, 50);
        int           daye  = randy.Next(0, 120);

        // Make sure all numbers are legal
        for (int a = 0; a < 50; a++)
        {
            for (int b = 0; b < 50; b++)
            {
                for (int i = 0; i < 120; i++)
                {
                    if (rainfall.worldArray[i][a, b] == 0.0f)
                    {
                        zerocount++;
                    }
                    else if (rainfall.worldArray[i][a, b] > 0.0f)
                    {
                        positivecount++;
                    }
                }
            }
        }

        // Debug.Log("0: " + zerocount + " / +: " + positivecount);
        Assert.AreEqual(120 * 50 * 50, zerocount + positivecount);
        Assert.AreNotSame(120 * 50 * 50, zerocount);
        Assert.GreaterOrEqual(testEquation.CalculateHumidityFromBase(daye, x, z), 0.0f);
        Assert.LessOrEqual(testEquation.CalculateHumidityFromBase(daye, x, z), 10.0f);

        // Print the first day of rain.

        for (int day = 10; day < 30; day++)
        {
            Debug.Log("Day " + day);
            Debug.Log(printArray(rainfall.worldArray[day]));
        }
    }
示例#3
0
    public void EarlyHumidityTest()
    {
        HumidityLayer.WORLDX = 50;
        HumidityLayer.WORLDZ = 50;
        // Test the single value Humidity Layer so I can get a sense for how the rainfall logic will work
        HumidityLayer testHumidityLayer = new HumidityLayer("Humidity", 6, 1);
        string        filePath          = @"C:\Users\William\Documents\World Generator Maps\CavemanWorld\DynamicCavemanWorld\Assets\Resources\CSV\";

        testHumidityLayer.readCSVFiles(filePath);

        Assert.AreEqual("Humidity", testHumidityLayer.layerName);
        Assert.AreEqual("Semi-static", testHumidityLayer.getType());
        Assert.AreEqual(1, testHumidityLayer.getRounding());
        Assert.AreEqual(6, testHumidityLayer.getNumFiles());
        Assert.AreEqual(6, testHumidityLayer.worldArray.Length);
        Assert.AreEqual(50, HumidityLayer.WORLDX);
        Assert.AreEqual(50, HumidityLayer.WORLDZ);
    }
示例#4
0
    // Mineral Layers
    // public MineralLayer surfaceStone;
    // public MineralLayer surfaceIron;
    // public MineralLayer surfaceMinerals;
    // public MineralLayer miningStone;
    // public MineralLayer miningIron;
    // public MineralLayer miningMinerals;

    // Constructor
    public World(int x, int z, bool random)
    {
        // Initialize the variables
        WorldX = x;
        WorldZ = z;
        SingleValueLayer.WORLDX = WorldX;
        SingleValueLayer.WORLDZ = WorldZ;
        this.elevation          = new SingleValueLayer("Elevation", "Semi-static", 1);
        this.elevationVertices  = new SingleValueLayer("ElevationVertices", "Semi-static", 1);
        this.highTemp           = new SingleValueLayer("HighTemp", "Semi-static", 0);
        this.lowTemp            = new SingleValueLayer("LowTemp", "Semi-static", 0);
        this.tempMidpt          = new SingleValueLayer("TempMidpoint", "Semi-static", 1);
        this.variance           = new SingleValueLayer("Variance", "Semi-static", 1);
        this.tempEquations      = new EquationLayer("TemperatureEquations", "Semi-static");
        this.temps    = new IntDayList[WorldX, WorldZ];
        this.humidity = new HumidityLayer("HumidityLayer", 6, 1);

        if (!random)
        {
            string filePathPrefix = @"CSV\";
            elevation.readCSVFile(filePathPrefix + "ElevationNiceMapA");
            // Debug.Log("**************************************");
            highTemp.readCSVFile(filePathPrefix + "HighTempNiceMapA");
            lowTemp.readCSVFile(filePathPrefix + "LowTempNiceMapA");
            tempMidpt.readCSVFile(filePathPrefix + "MidptNiceMapA");
            variance.readCSVFile(filePathPrefix + "VarianceNiceMapA");
            humidity.readCSVFiles(filePathPrefix);
        }
        else
        {
            DataGenerator generator = new DataGenerator(WorldX, WorldZ);
            Debug.Log(x + ", " + z);
            // Generate elevation layer
            elevation.worldArray = generator.CreateElevationLayer();
            // Generate temperature info
            float[][,] temporaryTemps = generator.CreateTemperatureLayers(4);
            highTemp.worldArray       = temporaryTemps[0];
            lowTemp.worldArray        = temporaryTemps[1];
            tempMidpt.worldArray      = generator.CreateStandardFloatLayer(20.2, 40.6, 4.0);
            variance.worldArray       = generator.CreateStandardFloatLayer(1.0, 16.0, 2.0);
            // Generate rain info
            for (int i = 0; i < 6; i++)
            {
                humidity.worldArray[i] = generator.CreateStandardFloatLayer(0.0, 10.0, 1.0);
            }
        }

        // Elevation info
        ConvertElevationToVertices();
        hillPer  = CalculateHillPercentage();
        oceanPer = CalculateOceanPercentage();
        Debug.Log("Elevation Models Complete!");
        // Temperature info
        tempEquations.createEquations(highTemp, lowTemp, tempMidpt, variance);
        // Calculate Years worth of temperature data
        // CreateYearsTemps();
        Debug.Log("Temperature Models Complete!");
        // Rainfall info
        rainfall      = humidity.GenerateWorldsYearOfRain();
        rainfallTotal = new SingleValueLayer("Yearly Rain Total", "Yearly", 1);
        // rainfallTotal.worldArray = rainfall.findYearTotalArray();
        Debug.Log("Rainfall Models Complete!");
        // Rivers info
        // Initialize Water Stats
        riverStats = new ObjectLayer("River Stats", "Semi-static");
        PopulateRivers();
        Debug.Log("Rivers Populated!");
        ResetStaticRiverLayers();
        ResetLastDayLayer();
        // Calculate Habitat Layer - ** for that we need 20 years of time run forward at initialization **
        HabitatInitialization();
        // When done initializing the habitats calculate a new year
        TempAndRainNewYear();
        Debug.Log("Habitats Created!");
    }