public void GetLengthOfDay_AboveEquatorIsLessThanAtEquator() { dynamic planetBuilder = new PlanetBuilder(); var planet = planetBuilder .WithOrbitalVelocity(Earth.OrbitalVelocityInMpsec) .WithAxes(General.AstronomicalUnitInMeters) .WithAngularVelocity(Earth.AngularVelocity) .WithRadius(200) // miles .WithLandSurfaceAreaPercentage(Earth.PercentageOfLandSuraceArea) .WithPolarTilt(23.4) .Build(); // Silly Workarounds for dynamic stuff var continents = planet.Continents as List<Continent>; // At winter continents.First().CentralLatitude = 39.7910; var winterLength = continents.First().LengthOfDay(); // Now at summer planet.TimeElapsedInSystem = planet.NumberOfDaysPerYear() / 2; var summerLength = continents.First().LengthOfDay(); Assert.IsTrue(planet.LengthOfDay() > winterLength); Assert.IsTrue(planet.LengthOfDay() < summerLength); }
private void btnSendCommands_Click(object sender, EventArgs e) { StringBuilder allResults = new StringBuilder(); try { var builder = new PlanetBuilder(); IParser parser = new InstructionParser(); PlanetDescription planetDescription = parser.Parse(tbCommands.Text); Queue<Robot> robots = builder.BuildPlanet(planetDescription); while (robots.Count > 0) { Robot robot = robots.Dequeue(); robot.ExecuteCommands(); string result = String.Format("{0} {1} {2}{3}", robot.CurrentPosition.X, robot.CurrentPosition.Y, robot.CurrentOrientation.ToString()[0], ((robot.IsLost) ? " LOST" : "")); allResults.Append(result.Trim() + "\r\n"); } } catch (MartianException ex) { allResults.Append(ex.Message + "\r\n"); } catch (Exception ex) { allResults.Append("Unhandled Exception: " + ex.Message + "\r\n"); } tbResult.Text = allResults.ToString(); }
// Use this for initialization void Start() { ProbMeter p = new ProbMeter(new double[] { 0, 2, 4, 8 }, new double[] { 2, 1, 1 }); Debug.Log(p.getValue(.25)); Debug.Log(p.getValue(.5)); Debug.Log(p.getValue(1)); int[] count = { 0, 0, 0, 0 }; for (int i = 0; i < 100000000; i++) { float num = PlanetBuilder.eDist(.5, 10000, Random.value); if (num < 10) { count[0]++; } else if (num < 100) { count[1]++; } else if (num < 1000) { count[2]++; } else if (num < 10000) { count[3]++; } } print(count[0] + " " + count[1] + " " + count[2] + " " + count[3]); }
public void X_AtHalfYearIsEqualToMajorAxis() { dynamic planetBuilder = new PlanetBuilder(); var planet = planetBuilder .WithAxes( majorAxis: General.AstronomicalUnitInMeters, minorAxis: 1000) .WithOrbitalVelocity(Earth.OrbitalVelocityInMpsec) .WithTimeElapsedInSystem(Planet.NumberOfDaysPerYear( majorAxis: General.AstronomicalUnitInMeters, minorAxis: 1000, velocity: Earth.OrbitalVelocityInMpsec) / 2) .Flat() .Build(); Assert.AreEqual( expected: General.AstronomicalUnitInMeters, actual: planet.DistanceToSolarEntity(), delta: 0.01); Assert.AreEqual( expected: -General.AstronomicalUnitInMeters, actual: planet.X, delta: 0.01); Assert.AreEqual( expected: 0, actual: planet.Y, delta: 0.01); }
public void RegionHeightAndWidth_AreFunctionsOfSurfaceArea() { dynamic planetBuilder = new PlanetBuilder(); var planet = planetBuilder .WithOrbitalVelocity(Earth.OrbitalVelocityInMpsec) .WithAxes(General.AstronomicalUnitInMeters) .WithRadius(2000) // miles .WithLandSurfaceAreaPercentage(Earth.PercentageOfLandSuraceArea) .Build(); foreach (var continent in planet.Continents) { var continentSurfaceArea = continent.SurfaceArea; var regionSurfaceArea = 0.0; foreach (var region in continent.Regions) { regionSurfaceArea += region.SurfaceArea; } Assert.AreEqual( expected: continent.SurfaceArea, actual: regionSurfaceArea, delta: 0.01); } }
public override void Update(GameTime gameTime) { EvaluateMouseCamControls(gameTime); Vector3 upVector = duneBuggyOne.BuggyObject.Transform.AbsoluteTransform.Translation - earth.Transform.AbsoluteTransform.Translation; Vector3 lengthVector = spaceShipOne.ShipObject.Transform.AbsoluteTransform.Translation - earth.Transform.AbsoluteTransform.Translation;; if (upVector != Vector3.Zero) { upVector.Normalize(); } duneBuggyOne.Update(gameTime); spaceShipOne.Update(gameTime, (lengthVector.Length() < (earth.radius * 1.05f))); duneBuggyCamera.Update(gameTime, earth, PlayerIndex.One); spaceShipCamera.Update(gameTime); PlanetBuilder.Update(); earth.Update(gameTime); if (input.EvaluateInputBinding("MainMenu")) { SystemCore.ScreenManager.AddAndSetActive(new MainMenuScreen()); } base.Update(gameTime); }
public PlanetViewModel() { planet = new Planet(); populatePlanetProperties(); var planetPopulated = PlanetBuilder.CalculateGeometry(planet.Separators, planet.Radius, planet.Points, planet.TriangleIndices); planet = planetPopulated; }
public override void OnInspectorGUI() { DrawDefaultInspector(); PlanetBuilder myScript = (PlanetBuilder)target; if (GUILayout.Button("Build Planet")) { myScript.BuildPlanet(); } }
public void LengthOfDay_YieldsCorrectEarthDay() { dynamic planetBuilder = new PlanetBuilder(); var planet = planetBuilder .WithAngularVelocity(Earth.AngularVelocity) .Flat() .Build(); Assert.AreEqual( expected: Earth.LengthOfDay / 2, //12 hours day, 12 hours night actual: planet.LengthOfDay(), delta: 0.01); }
public void generateStuff() { System.Random rand = new System.Random(Random.Range(int.MinValue, int.MaxValue)); for (int i = 0; i < 10; i++) { Planet planet = new Planet(PlanetBuilder.eDist(100000, 1000000, rand.NextDouble()), new LongPos(rand.Next(-30000, 30000) * 10000L, rand.Next(-20, 20) * 10000L, rand.Next(-30000, 30000) * 10000L), rand.Next(int.MinValue, int.MaxValue)); planets.Add(planet); } star = new Star(3452, 23000000, new LongPos(0, 0, 0)); }
public void NumberOfDaysPerYear_GetCalculationIsApproximatelyCorrect() { dynamic planetBuilder = new PlanetBuilder(); var planet = planetBuilder .WithOrbitalVelocity(Earth.OrbitalVelocityInMpsec) .WithAxes(General.AstronomicalUnitInMeters) .Flat() .Build(); var result = planet.NumberOfDaysPerYear(); Assert.AreEqual( expected: Earth.YearLengthInDays, actual: result, delta: 0.01); }
public void GetLengthOfDay_ReturnsContinentLengthOfDay() { dynamic planetBuilder = new PlanetBuilder(); var planet = planetBuilder .WithOrbitalVelocity(Earth.OrbitalVelocityInMpsec) .WithAxes(General.AstronomicalUnitInMeters) .WithRadius(200) // miles .WithLandSurfaceAreaPercentage(Earth.PercentageOfLandSuraceArea) .Build(); // Silly Workarounds for dynamic stuff var continents = planet.Continents as List<Continent>; var regions = continents.First().Regions as List<Region>; Assert.AreEqual( expected: planet.LengthOfDay(), actual: regions.First().LengthOfDay()); }
public override void Update(GameTime gameTime) { if (input.KeyPress(Keys.Space)) { SystemCore.Wireframe = !SystemCore.Wireframe; } solarSystem.Update(gameTime); //RaycastTest(); var earth = SystemCore.GameObjectManager.GetObject("earth"); //DebugShapeRenderer.AddBoundingSphere( // new BoundingSphere( // testPlanetSurfacePosition.GetPosition(earth as Planet, ship.HighPrecisionPositionComponent), 1000f), // Color.Red); //DebugShapeRenderer.AddLine(earth.Transform.WorldMatrix.Translation, // earth.Transform.WorldMatrix.Translation + earth.Transform.WorldMatrix.Forward*7000, Color.Blue); //DebugShapeRenderer.AddLine(earth.Transform.WorldMatrix.Translation, //earth.Transform.WorldMatrix.Translation + earth.Transform.WorldMatrix.Right * 7000, Color.Red); //DebugShapeRenderer.AddLine(earth.Transform.WorldMatrix.Translation, //earth.Transform.WorldMatrix.Translation + earth.Transform.WorldMatrix.Up * 7000, Color.Green); if (!firstTimePlacement) { ship.GetComponent <HighPrecisionPosition>().Position = earth.GetComponent <HighPrecisionPosition>().Position + earth.Transform.AbsoluteTransform.Left * shipDistanceOnFirstPlacement; ship.Transform.SetLookAndUp(SolarSystem.GetRenderPosition(ship.HighPrecisionPositionComponent.Position, earth.GetComponent <HighPrecisionPosition>().Position), Vector3.Up); firstTimePlacement = true; } if (!SystemWarGlobalSettings.BuildPatchesOnBackgroundThread) { PlanetBuilder.Update(); } base.Update(gameTime); }
public void HeightAndWidth_AreFunctionsOfSurfaceArea() { dynamic planetBuilder = new PlanetBuilder(); var planet = planetBuilder .WithOrbitalVelocity(Earth.OrbitalVelocityInMpsec) .WithAxes(General.AstronomicalUnitInMeters) .WithRadius(Earth.Radius) .WithLandSurfaceAreaPercentage(Earth.PercentageOfLandSuraceArea) .Build(); foreach (var continent in planet.Continents) { var calcSurfaceArea = continent.Width * continent.Height; Assert.AreEqual( expected: continent.SurfaceArea, actual: calcSurfaceArea, delta: 0.01); } }
public void GetLengthOfDay_AtEquatorIsEqualToPlanetLengthOfDay() { dynamic planetBuilder = new PlanetBuilder(); var planet = planetBuilder .WithOrbitalVelocity(Earth.OrbitalVelocityInMpsec) .WithAxes(General.AstronomicalUnitInMeters) .WithAngularVelocity(Earth.AngularVelocity) .WithRadius(200) // miles .WithLandSurfaceAreaPercentage(Earth.PercentageOfLandSuraceArea) .Build(); // Silly Workarounds for dynamic stuff var continents = planet.Continents as List<Continent>; // Set to Equator continents.First().CentralLatitude = 0; Assert.AreEqual( expected: planet.LengthOfDay(), actual: continents.First().LengthOfDay(), delta: 0.01); }
//later will have many parameters public Planet(float r, LongPos pos, int _seed) : base(_seed, r, pos) //Vector3 sp, float r) { //generate the planet surface data ModuleBase finalTerrain, finalTexture; List <Blueprint> blueprints; PlanetBuilder.genPlanetData(seed, out finalTerrain, out finalTexture, out blueprints); noise = new NoiseHandler(radius, finalTerrain, finalTexture); //terrain = new TerrainSystem(this, radius); //surface = new SurfaceSystem(radius, 400); surface = new SurfaceSystem(this, radius, (int)(radius / 50), blueprints); //number of surface units per side is radius/50 lod = new LODSystem(this); //TODO: does this 16 hold relavance? startLev = Mathf.CeilToInt(Mathf.Log(radius / TerrainObject.chunkWidth, 2)) - 1; createRep(); }
public void TestFromFiles() { foreach (TestDescription description in Tests) { IParser parser = new InstructionParser(); PlanetDescription planetDescription = parser.Parse(description.Test); Queue<Robot> robots = new PlanetBuilder().BuildPlanet(planetDescription); StringBuilder allResults = new StringBuilder(); while (robots.Count > 0) { Robot robot = robots.Dequeue(); robot.ExecuteCommands(); string result = String.Format("{0} {1} {2}{3}", robot.CurrentPosition.X, robot.CurrentPosition.Y, robot.CurrentOrientation.ToString()[0], ((robot.IsLost) ? " LOST" : "")); allResults.Append(result.Trim()+"\r\n"); } Assert.AreEqual(allResults.ToString().Trim(), description.ExpectedResult.Trim()); } }
protected Galaxy(Configuration configuration) { Galaxy.Instance = this; this.IsValid = true; this.builderList = new List<Builder>(); StarBuilder starBuilder = new StarBuilder(); ConstellationBuilder constellationsBuilder = new ConstellationBuilder(); WarpBuilder warpBuilder = new WarpBuilder(); SpawnBuilder spawnBuilder = new SpawnBuilder(); PlanetBuilder planetBuilder = new PlanetBuilder(); HomeBuilder homeBuilder = new HomeBuilder(); StrategicResourceBuilder strategicResourceBuilder = new StrategicResourceBuilder(); LuxuryResourceBuilder luxuryResourceBuilder = new LuxuryResourceBuilder(); this.builderList.Add(starBuilder); this.builderList.Add(constellationsBuilder); this.builderList.Add(warpBuilder); this.builderList.Add(spawnBuilder); this.builderList.Add(planetBuilder); this.builderList.Add(homeBuilder); this.builderList.Add(strategicResourceBuilder); this.builderList.Add(luxuryResourceBuilder); this.Configuration = configuration; this.Stars = new List<StarSystem>(); this.Warps = new List<WarpLine>(); this.Constellations = new List<Constellation>(); this.Regions = new List<Region>(); this.SpawnStars = new List<StarSystem>(); //this.Planets = new List<Planet>(); foreach (Builder builder in this.builderList) { if (this.IsValid) { builder.Execute(); this.IsValid = this.IsValid && builder.Result; } } if (this.IsValid) { this.IsValid = Balancing.Balancing.isBalanced(); } if (!this.IsValid) { System.Diagnostics.Trace.WriteLine("--Galaxy generation failed--"); System.Diagnostics.Trace.WriteLine("--Generation defects summary--"); foreach (Builder b in this.builderList) { foreach (string text in b.Defects) { System.Diagnostics.Trace.WriteLine(b.Name + " -> " + text); } } System.Diagnostics.Trace.WriteLine("--Generation defects end--"); } }
public void SurfaceArea_AddsUpToPlanetSurfaceArea() { dynamic planetBuilder = new PlanetBuilder(); var planet = planetBuilder .WithOrbitalVelocity(Earth.OrbitalVelocityInMpsec) .WithAxes(General.AstronomicalUnitInMeters) .WithRadius(Earth.Radius) .WithLandSurfaceAreaPercentage(Earth.PercentageOfLandSuraceArea) .Build(); var continentSurfaceArea = 0.0; foreach (var continent in planet.Continents) { continentSurfaceArea += continent.SurfaceArea; } Assert.AreEqual( expected: planet.SurfaceAreaOfLand(), actual: continentSurfaceArea, delta: 0.01); }
// Use this for initialization void Start() { planetBuilder = GetComponent <PlanetBuilder>(); spawnedPlanets = new List <GameObject>(); SpawnHomePlanet(); }