コード例 #1
0
        public void GivenDeadCellWithAnyNumberOtherThanThreeLiveNeighboursShouldReturnDeadCell(char cell, int countOfLiveNeighbours, char expected)
        {
            var cellUpdater = new CellUpdater();
            var actual      = cellUpdater.GetUpdatedCell(cell, countOfLiveNeighbours);

            Assert.Equal(expected, actual);
        }
コード例 #2
0
        /// <summary>
        /// 生成
        /// </summary>
        /// <param name="part"></param>
        /// <param name="value"></param>
        /// <returns></returns>
        public override AttributeBase CreateKeyFrame(SpritePart part, ValueBase value)
        {
            Value v    = (Value)value;
            var   cell = part.Root.CellMap(v.mapId);

            return(CellUpdater.Create(v.mapId, cell.FindCell(v.name)));
        }
コード例 #3
0
        public void GivenLiveCellWithLessThanTwoLiveNeighboursShouldReturnDeadCell(char cell, int countOfLiveNeighbours, char expected)
        {
            var cellUpdater = new CellUpdater();
            var actual      = cellUpdater.GetUpdatedCell(cell, countOfLiveNeighbours);

            Assert.Equal(expected, actual);
        }
コード例 #4
0
 public void UpdatePlanetaryData(PlanetData PD)
 {
     StartTime = Process.GetCurrentProcess().TotalProcessorTime;
     //update temps for the cell stack
     for (int i = 0; i < cellsPerUpdate; i++, cellindex++)
     {
         if (cellindex == Cell.CountAtLevel(PD.gridLevel))
         {
             cellindex = 0;
             BufferFlip(PD);
             cycleTime   += (Process.GetCurrentProcess().TotalProcessorTime.TotalMilliseconds - StartTime.TotalMilliseconds) * 1000;
             AvgCycleTime = cycleTime / Cell.CountAtLevel(PD.gridLevel);
             cycleTime    = 0;
             if (WeatherSettings.SD.statistics)
             {
                 Statistics.PrintStat(PD);
             }
             return;
         }
         Cell cell = new Cell(cellindex);
         //update the cell
         CellUpdater.UpdateCell(PD, cell);
     }
     cycleTime += (Process.GetCurrentProcess().TotalProcessorTime.TotalMilliseconds - StartTime.TotalMilliseconds) * 1000;
 }
コード例 #5
0
        public static double SH(int database, float altitude, float temperature)
        //Mean mass of molecule Mm = M * Na (Molar mass * Avogadro constant) = M * UGC/kb (Molar mass * UniversalGasConstant / Boltzmann constant)
        //ScaleHeight SH = R*T/g = Kb*T/(Mm*g) (https://en.wikipedia.org/wiki/Scale_height) = UGC * T / (M * g)
        //ScaleHeight = UniversalGasConstant * Temperature / (AtmosphereMolarMass * gravity(altitude))
        //NOTE: PD.SH_correction is applied to have the resulting pressure curve match on average with the pressure curve in KSP
        {
            PlanetData PD = WeatherDatabase.PlanetaryData[database];

            return(CellUpdater.UGC * PD.SH_correction / PD.atmoData.M / (float)CellUpdater.G(PD.index, altitude) * temperature);
        }
コード例 #6
0
ファイル: CA.cs プロジェクト: noah-art3mis/WEAV
    private void Start()
    {
        settings = GetComponent <SettingsManager>();
        myCamera = GetComponent <MyCamera>();
        updater  = GetComponent <CellUpdater>();

        gridSize = new Vector2(Defaults.GRID_SIZE, Defaults.GRID_SIZE);

        arraySize      = (int)gridSize.x;
        maxGenerations = (int)gridSize.y;

        cells   = new int[arraySize];
        nextgen = new int[cells.Length];

        CreateSprites(Defaults.SPRITE_POOL_SIZE);
    }
コード例 #7
0
        private static List <KWSCellMap <WeatherCell> > InitCalcs(PlanetData PD)
        {
            List <KWSCellMap <WeatherCell> > tempMap = new List <KWSCellMap <WeatherCell> >();

            for (int i = 0; i < PD.layers; i++)
            {
                tempMap.Add(new KWSCellMap <WeatherCell>(PD.gridLevel));
            }
            float basePressure = (float)FlightGlobals.getStaticPressure(0, PD.body) * 1000;

            for (int AltLayer = 0; AltLayer < PD.layers; AltLayer++)
            {
                foreach (Cell cell in Cell.AtLevel(PD.gridLevel))
                {
                    WeatherCell wCell = new WeatherCell();

                    wCell.temperature = GetInitTemperature(PD, AltLayer, cell);
                    wCell.TempChange  = 0;

                    if (AltLayer == 0)
                    {
                        wCell.CCN = 1;

                        wCell.pressure         = basePressure;
                        wCell.relativeHumidity = PD.biomeDatas[WeatherFunctions.GetBiome(PD.index, cell)].FLC * 0.85f;  //* wCell.temperature / 288.15f
                    }
                    else
                    {
                        wCell.CCN = 0;

                        wCell.pressure = (float)(tempMap[AltLayer - 1][cell].pressure
                                                 * Math.Exp(-WeatherFunctions.GetDeltaLayerAltitude(PD.index, cell) / (CellUpdater.UGC * PD.SH_correction / PD.atmoData.M / CellUpdater.G(PD.index, AltLayer * WeatherFunctions.GetDeltaLayerAltitude(PD.index, cell)) * tempMap[AltLayer - 1][cell].temperature)));
                        wCell.relativeHumidity = (PD.biomeDatas[WeatherFunctions.GetBiome(PD.index, cell)].FLC * wCell.temperature / 288.15f) * 0.4f;
                    }

                    wCell.windVector        = new Vector3(0f, 0f, 0f);
                    wCell.flowPChange       = 0;
                    tempMap[AltLayer][cell] = wCell;
                }
            }


            return(tempMap);
        }
コード例 #8
0
        private static List <KWSCellMap <WeatherCell> > InitStratoCalcs(PlanetData PD)
        {
            List <KWSCellMap <WeatherCell> > tempMap = new List <KWSCellMap <WeatherCell> >();

            for (int i = 0; i < PD.stratoLayers; i++)
            {
                tempMap.Add(new KWSCellMap <WeatherCell>(PD.gridLevel));
            }
            for (int layer = 0; layer < PD.stratoLayers; layer++)
            {
                foreach (Cell cell in Cell.AtLevel(PD.gridLevel))
                {
                    WeatherCell wCell = new WeatherCell();

                    wCell.CCN         = 0;
                    wCell.temperature = GetInitTemperature(PD, layer + layers, cell);
                    wCell.TempChange  = 0;
                    if (layer == 0)
                    {
                        wCell.pressure = (float)(PD.LiveMap[layers - 1][cell].pressure
                                                 * Math.Exp(-WeatherFunctions.GetDeltaLayerAltitude(PD.index, cell) / (CellUpdater.UGC * PD.SH_correction / PD.atmoData.M / CellUpdater.G(PD.index, (layers + layer) * WeatherFunctions.GetDeltaLayerAltitude(PD.index, cell)) * PD.LiveMap[layers - 1][cell].temperature)));
                    }
                    else
                    {
                        wCell.pressure = (float)(tempMap[layer - 1][cell].pressure
                                                 * Math.Exp(-WeatherFunctions.GetDeltaLayerAltitude(PD.index, cell) / (CellUpdater.UGC * PD.SH_correction / PD.atmoData.M / CellUpdater.G(PD.index, (layers + layer) * WeatherFunctions.GetDeltaLayerAltitude(PD.index, cell)) * tempMap[layer - 1][cell].temperature)));
                    }


                    wCell.relativeHumidity = 0;

                    wCell.windVector     = new Vector3(0f, 0f, 0f);
                    tempMap[layer][cell] = wCell;
                }
            }
            return(tempMap);
        }