public void PrintSolution() { var latticeCalculator = new SliceSphereLatticeCalculator(new TurtleCircleLatticeCalculator()); var riskCalculator = new AStarRiskCalculator(); var puzzle = new RiskyMoonPuzzle(latticeCalculator, riskCalculator); Console.WriteLine("Solution: {0:N10}", puzzle.Solve()); }
public void CompareSliceToNaiveForVariousRadii([Range(2, 20)] int radius) { var naive = new ParallelNaiveSphereLatticeCalculator(); var slice = new SliceSphereLatticeCalculator(new TurtleCircleLatticeCalculator()); var expected = naive.FindLatticePoints(radius).ToArray(); var actual = slice.FindLatticePoints(radius); actual.AssertSequenceEquivalentTo(expected); }
public void FirstFiftyGroupedByRisk() { var latticeCalculator = new SliceSphereLatticeCalculator(new TurtleCircleLatticeCalculator()); var riskCalculator = new AStarRiskCalculator(); var groups = Enumerable.Range(1, 50).AsParallel() .Select(radius => { var stations = latticeCalculator.FindLatticePoints(radius).Select(coord => new Station(coord)); return riskCalculator.CalculateRisk(stations, radius); }) .GroupBy(result => result.TotalRisk) .OrderBy(grp => grp.Key); foreach(var grp in groups) { Console.Write("{0}, {1}:", grp.Key, grp.First().TotalDistanceRatio); foreach(var value in grp.OrderBy(result => result.Radius)) { Console.Write(" {0:N0}", value.Radius); } Console.WriteLine(); } }
private RiskResult FindResult(int radius) { var latticeCalculator = new SliceSphereLatticeCalculator(new TurtleCircleLatticeCalculator()); var riskCalculator = new AStarRiskCalculator(); var stations = latticeCalculator.FindLatticePoints(radius).Select(coord => new Station(coord)); return riskCalculator.CalculateRisk(stations, radius); }
public void MaxZ() { var latticeCalculator = new SliceSphereLatticeCalculator(new TurtleCircleLatticeCalculator()); var riskCalculator = new AStarRiskCalculator(); var results = Enumerable.Range(1, 50).AsParallel() .Select(radius => { var stations = latticeCalculator.FindLatticePoints(radius).Select(coord => new Station(coord)); return riskCalculator.CalculateRisk(stations, radius); }) .OrderBy(result => result.Radius); foreach (var result in results) { var maxZ = result.Path.Max(path => path.Source.CartesianLocation.Z - path.Target.CartesianLocation.Z); Console.WriteLine("{0}: {1}", result.Radius, maxZ); } }