コード例 #1
0
        public void testColonyToxicityCost()
        {
            SystemBodyInfoDB earthBodyDB = new SystemBodyInfoDB {
                BodyType = BodyType.Terrestrial, SupportsPopulations = true
            };
            NameDB earthNameDB = new NameDB("Earth");
            double expectedCost;
            string gasSym;

            Dictionary <string, AtmosphericGasSD> lowToxicGases, highToxicGases, benignGases;
            AtmosphericGasSD oxygenGas;

            lowToxicGases  = new Dictionary <string, AtmosphericGasSD>();
            highToxicGases = new Dictionary <string, AtmosphericGasSD>();
            benignGases    = new Dictionary <string, AtmosphericGasSD>();
            oxygenGas      = new AtmosphericGasSD();

            //Separate all the gases into the lists above
            foreach (KeyValuePair <string, AtmosphericGasSD> kvp in _gasDictionary)
            {
                gasSym = kvp.Key;
                if (gasSym == "H2" || gasSym == "CH4" || gasSym == "NH3" || gasSym == "CO" || gasSym == "NO" || gasSym == "H2S" || gasSym == "NO2" || gasSym == "SO2")
                {
                    lowToxicGases.Add(gasSym, kvp.Value);
                }
                else if (gasSym == "Cl2" || gasSym == "F2" || gasSym == "Br2" || gasSym == "I2")
                {
                    highToxicGases.Add(gasSym, kvp.Value);
                }
                else if (gasSym == "O")
                {
                    oxygenGas = kvp.Value;
                }
                else
                {
                    benignGases.Add(gasSym, kvp.Value);
                }
            }

            // @todo: set up two nested loops - one for list of species, one for list of gases
            // test a large number of different inputs
            AtmosphereDB weirdAtmosphereDB;
            Dictionary <AtmosphericGasSD, float> atmoGasses = new Dictionary <AtmosphericGasSD, float>();

            // Test the "low" toxic gases (colony cost 2.0 minimum
            foreach (KeyValuePair <string, AtmosphericGasSD> kvp in lowToxicGases)
            {
                expectedCost = 2.0;
                gasSym       = kvp.Key;
                atmoGasses.Clear();
                atmoGasses.Add(_gasDictionary[gasSym], 0.1f);
                weirdAtmosphereDB = new AtmosphereDB(1f, true, 71, 1f, 1f, 0.3f, 57.2f, atmoGasses); //TODO what's our greenhouse factor an pressure?
                _weirdatmosPlanet = setAtmosphere(weirdAtmosphereDB);

                Assert.AreEqual(expectedCost, SpeciesProcessor.ColonyCost(_weirdatmosPlanet, _humanSpecies.GetDataBlob <SpeciesDB>()));
            }

            // Test the "high" toxic gases (colony cost 3.0 minimum)
            foreach (KeyValuePair <string, AtmosphericGasSD> kvp in highToxicGases)
            {
                expectedCost = 3.0;
                gasSym       = kvp.Key;
                atmoGasses.Clear();
                atmoGasses.Add(_gasDictionary[gasSym], 0.1f);
                weirdAtmosphereDB = new AtmosphereDB(1f, true, 71, 1f, 1f, 0.3f, 57.2f, atmoGasses); //TODO what's our greenhouse factor an pressure?
                _weirdatmosPlanet = setAtmosphere(weirdAtmosphereDB);

                Assert.AreEqual(expectedCost, SpeciesProcessor.ColonyCost(_weirdatmosPlanet, _humanSpecies.GetDataBlob <SpeciesDB>()));
            }

            // Test the "benign" toxic gases (no affect on colony cost, but no oxygen means 2.0)
            foreach (KeyValuePair <string, AtmosphericGasSD> kvp in lowToxicGases)
            {
                expectedCost = 2.0;
                gasSym       = kvp.Key;
                atmoGasses.Clear();
                atmoGasses.Add(_gasDictionary[gasSym], 0.1f);
                weirdAtmosphereDB = new AtmosphereDB(1f, true, 71, 1f, 1f, 0.3f, 57.2f, atmoGasses); //TODO what's our greenhouse factor an pressure?
                _weirdatmosPlanet = setAtmosphere(weirdAtmosphereDB);

                Assert.AreEqual(expectedCost, SpeciesProcessor.ColonyCost(_weirdatmosPlanet, _humanSpecies.GetDataBlob <SpeciesDB>()));
            }

            // test with atmposheres composed of two toxic gases that have the same colony cost
            foreach (KeyValuePair <string, AtmosphericGasSD> kvp1 in lowToxicGases)
            {
                foreach (KeyValuePair <string, AtmosphericGasSD> kvp2 in lowToxicGases)
                {
                    expectedCost = 2.0;
                    string gasSym1 = kvp1.Key;
                    string gasSym2 = kvp2.Key;
                    if (gasSym1 == gasSym2)
                    {
                        continue;
                    }

                    atmoGasses.Clear();
                    atmoGasses.Add(lowToxicGases[gasSym1], 0.1f);
                    atmoGasses.Add(lowToxicGases[gasSym2], 0.1f);
                    weirdAtmosphereDB = new AtmosphereDB(1f, true, 71, 1f, 1f, 0.3f, 57.2f, atmoGasses); //TODO what's our greenhouse factor an pressure?
                    _weirdatmosPlanet = setAtmosphere(weirdAtmosphereDB);

                    Assert.AreEqual(expectedCost, SpeciesProcessor.ColonyCost(_weirdatmosPlanet, _humanSpecies.GetDataBlob <SpeciesDB>()));
                }
            }

            // test with atmposheres composed of two toxic gases that have the same colony cost
            foreach (KeyValuePair <string, AtmosphericGasSD> kvp1 in highToxicGases)
            {
                foreach (KeyValuePair <string, AtmosphericGasSD> kvp2 in highToxicGases)
                {
                    expectedCost = 3.0;
                    string gasSym1 = kvp1.Key;
                    string gasSym2 = kvp2.Key;
                    if (gasSym1 == gasSym2)
                    {
                        continue;
                    }

                    atmoGasses.Clear();
                    atmoGasses.Add(highToxicGases[gasSym1], 0.1f);
                    atmoGasses.Add(highToxicGases[gasSym2], 0.1f);
                    weirdAtmosphereDB = new AtmosphereDB(1f, true, 71, 1f, 1f, 0.3f, 57.2f, atmoGasses); //TODO what's our greenhouse factor an pressure?
                    _weirdatmosPlanet = setAtmosphere(weirdAtmosphereDB);

                    Assert.AreEqual(expectedCost, SpeciesProcessor.ColonyCost(_weirdatmosPlanet, _humanSpecies.GetDataBlob <SpeciesDB>()));
                }
            }

            // test with atmospheres composed of two toxic gases that have different colony costs

            foreach (KeyValuePair <string, AtmosphericGasSD> kvp1 in lowToxicGases)
            {
                foreach (KeyValuePair <string, AtmosphericGasSD> kvp2 in highToxicGases)
                {
                    expectedCost = 3.0;
                    string gasSym1 = kvp1.Key;
                    string gasSym2 = kvp2.Key;
                    if (gasSym1 == gasSym2)
                    {
                        continue;
                    }

                    atmoGasses.Clear();
                    atmoGasses.Add(lowToxicGases[gasSym1], 0.1f);
                    atmoGasses.Add(highToxicGases[gasSym2], 0.1f);
                    weirdAtmosphereDB = new AtmosphereDB(1f, true, 71, 1f, 1f, 0.3f, 57.2f, atmoGasses); //TODO what's our greenhouse factor an pressure?
                    _weirdatmosPlanet = setAtmosphere(weirdAtmosphereDB);

                    Assert.AreEqual(expectedCost, SpeciesProcessor.ColonyCost(_weirdatmosPlanet, _humanSpecies.GetDataBlob <SpeciesDB>()));
                }
            }


            //Toxic Gasses(CC = 2): Hydrogen(H2), Methane(CH4), Ammonia(NH3), Carbon Monoxide(CO), Nitrogen Monoxide(NO), Hydrogen Sulfide(H2S), Nitrogen Dioxide(NO2), Sulfur Dioxide(SO2)
            //Toxic Gasses(CC = 3): Chlorine(Cl2), Florine(F2), Bromine(Br2), and Iodine(I2)
            //Toxic Gasses at 30% or greater of atm: Oxygen(O2) *


            Assert.AreEqual(1.0, SpeciesProcessor.ColonyCost(_earthPlanet, _humanSpecies.GetDataBlob <SpeciesDB>()));
        }
コード例 #2
0
        public void TestExport()
        {
            WeightedList <AtmosphericGasSD> atmoGases = new WeightedList <AtmosphericGasSD>();
            AtmosphericGasSD gas = new AtmosphericGasSD();

            gas.BoilingPoint   = 100;
            gas.MeltingPoint   = 0;
            gas.ChemicalSymbol = "H20";
            gas.Name           = "Water";
            gas.IsToxic        = false;

            atmoGases.Add(1.0, gas);

            gas.BoilingPoint   = 100;
            gas.MeltingPoint   = 0;
            gas.ChemicalSymbol = "H2O";
            gas.Name           = "Water Second take";
            gas.IsToxic        = false;

            atmoGases.Add(1.0, gas);

            StaticDataManager.ExportStaticData(atmoGases, "AtmoGasesExportTest.json");

            List <CommanderNameThemeSD> nameThemes = new List <CommanderNameThemeSD>();
            CommanderNameThemeSD        nameTheme  = new CommanderNameThemeSD();

            nameTheme.NameList  = new List <CommanderNameSD>();
            nameTheme.ThemeName = "The Creators";

            CommanderNameSD name = new CommanderNameSD();

            name.First    = "Greg";
            name.Last     = "Nott";
            name.IsFemale = false;

            nameTheme.NameList.Add(name);

            name.First    = "Rod";
            name.Last     = "Serling";
            name.IsFemale = false;

            nameTheme.NameList.Add(name);

            nameThemes.Add(nameTheme);

            StaticDataManager.ExportStaticData(nameThemes, "CommanderNameThemeExportTest.json");

            StaticDataManager.ExportStaticData(VersionInfo.PulsarVersionInfo, "VersionInfoExportTest.vinfo");

            List <MineralSD> minList = new List <MineralSD>();
            MineralSD        min     = new MineralSD();

            min.Abundance = new Dictionary <BodyType, double>();
            min.Abundance.Add(BodyType.Asteroid, 0.01);
            min.Abundance.Add(BodyType.Comet, 0.05);
            min.Abundance.Add(BodyType.DwarfPlanet, 0.075);
            min.Abundance.Add(BodyType.GasDwarf, 0.1);
            min.Abundance.Add(BodyType.GasGiant, 1.0);
            min.Abundance.Add(BodyType.IceGiant, 0.5);
            min.Abundance.Add(BodyType.Moon, 0.5);
            min.Abundance.Add(BodyType.Terrestrial, 1.0);
            min.ID          = Guid.NewGuid();
            min.Name        = "Sorium";
            min.Description = "des";
            minList.Add(min);

            StaticDataManager.ExportStaticData(minList, "MineralsExportTest.json");

            //Dictionary<ID, TechSD> techs = Tech();
            //TechSD tech1 = new TechSD();
            //tech1.Name = "Trans-Newtonian Technology";
            //tech1.Requirements = new Dictionary<ID, int>();
            //tech1.Description = "Unlocks almost all other technology.";
            //tech1.Cost = 1000;
            //tech1.Category = ResearchCategories.ConstructionProduction;
            //tech1.ID = ID.NewGuid();

            //TechSD tech2 = new TechSD();
            //tech2.Name = "Construction Rate";
            //tech2.Requirements = new Dictionary<ID, int>();
            //tech2.Requirements.Add(tech1.ID, 0);
            //tech2.Description = "Boosts Construction Rate by 12 BP";
            //tech2.Cost = 3000;
            //tech2.Category = ResearchCategories.ConstructionProduction;
            //tech2.ID = ID.NewGuid();

            //techs.Add(tech1.ID, tech1);
            //techs.Add(tech2.ID, tech2);



            //StaticDataManager.ExportStaticData(techs, "./TechnologyDataExportTest.json");

            //InstallationSD install = new InstallationSD();
            //install.Name = "Mine";
            //install.Description = "Employs population to mine transnewtonian resources.";
            //install.PopulationRequired = 1;
            //install.CargoSize = 1;
            //install.BaseAbilityAmounts = new Dictionary<AbilityType, int>();
            //install.BaseAbilityAmounts.Add(AbilityType.Mine, 1);
            //install.TechRequirements = new List<ID>();
            //install.TechRequirements.Add(tech1.ID); //use trans-newtonian techology you just added to the tech list
            //install.ResourceCosts = new Dictionary<ID, int>();
            //install.ResourceCosts.Add(min.ID,60); //use Sorium that you just added to the mineral list
            //install.WealthCost = 120;
            //install.BuildPoints = 120;

            //installations.Add(install);



            //ComponentAbilitySD launchAbility = new ComponentAbilitySD();
            //launchAbility.Ability = AbilityType.LaunchMissileSize;
            //launchAbility.AbilityAmount = new List<float>() { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
            //launchAbility.CrewAmount = new List<float>() { 3, 6, 9, 12, 15, 18, 21, 24, 27, 30};
            ////launchAbility.ID = ID.NewGuid();
            //launchAbility.Name = "Missile Launcher Size";
            //launchAbility.Description = "Can fire a missile of this size or smaller";
            //launchAbility.WeightAmount = new List<float>() { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
            //launchAbility.TechRequirements = new List<ID>() { };

            //ComponentAbilitySD reloadAbility = new ComponentAbilitySD();
            //reloadAbility.Name = "Missile Launcher Reload Rate";
            //reloadAbility.Description = "Speed at which this launcher can reload from a magazine";
            ////reloadAbility.ID = ID.NewGuid();
            //reloadAbility.Ability = AbilityType.ReloadRateFromMag;
            //reloadAbility.AbilityAmount = new List<float>() { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
            //reloadAbility.CrewAmount = new List<float>() { };

            //ComponentSD missileLauncher = new ComponentSD();
            //missileLauncher.ComponentAbilitySDs = new List<ComponentAbilitySD>() { launchAbility, reloadAbility};
            //missileLauncher.Name = "MissileLauncher";
            //missileLauncher.Description = "Can launch Missiles and be reloaded via a magazine";
            //missileLauncher.ID = ID.NewGuid();

            ////StaticDataManager.ExportStaticData(launchAbility, "./launcherabilitytest.json");
            ////StaticDataManager.ExportStaticData(reloadAbility, "./launcherabilitytest.json");
            //Dictionary<ID, ComponentSD> components = new Dictionary<ID, ComponentSD>();
            //components.Add(missileLauncher.ID, missileLauncher);
            //StaticDataManager.ExportStaticData(components, "./Componentstest.json");

            // test export of galaxy settings:
            GalaxyFactory gf = new GalaxyFactory(true, 1);

            StaticDataManager.ExportStaticData(gf.Settings, "SystemGenSettings.json");
        }
コード例 #3
0
 public bool Equals(AtmosphericGasSD other)
 {
     return(string.Equals(ChemicalSymbol, other.ChemicalSymbol));
 }