Esempio n. 1
0
 internal MapPreview(IEnumerable <StarSystemBuilder> systems, HashSet <StarData> homewolrds, IEnumerable <Wormhole> starlanes, SystemEvaluator evaluator)
 {
     this.Systems = systems.Select(x => new SystemPreview(
                                       x.Star,
                                       homewolrds.Contains(x.Star),
                                       evaluator.StartingScore(x.Star, x.Planets),
                                       evaluator.PotentialScore(x.Star, x.Planets)
                                       )).ToList();
     this.Starlanes = starlanes.Select(x => new WormholeInfo(x)).ToList();
 }
Esempio n. 2
0
        private StarSystemBuilder generateSystem(StarNamer namer, Vector2D position, Random rng, SystemEvaluator evaluator, double startingScore, double potentialScore, bool isHomeSystem)
        {
            var starType = isHomeSystem ? this.homeStarType : starTypes[rng.Next(starTypes.Length)];
            var starName = namer.NextName();

            var fixedParts = new StarSystemBuilder(
                starType.Hue,
                (float)Methods.Lerp(rng.NextDouble(), starType.MinScale, starType.Maxscale),
                starName, position,
                new List <StarTraitType>(starType.Traits.Select(x => this.starTraits[x]))
                );
            var usedPositions = new HashSet <int>();

            if (isHomeSystem)
            {
                fixedParts.AddPlanet(this.homeworldPosition, PlanetType.Rock, this.homeworldSize, this.homeworldTraits.Select(x => this.planetTraits[x]));
                usedPositions.Add(this.homeworldPosition);
            }

            var systems = new List <StarSystemBuilder>();

            for (int i = 0; i < SysGenRepeats; i++)
            {
                var system = new StarSystemBuilder(fixedParts);
                systems.Add(system);
                var planets      = rng.Next(5);
                var bodyPosition = 1;
                for (int p = 0; p < planets; p++)
                {
                    var type = bodyTypes()[rng.Next(3)];
                    var size = Math.Round(Methods.Lerp(rng.NextDouble(), 50, 200));
                    while (usedPositions.Contains(bodyPosition))
                    {
                        bodyPosition++;
                    }

                    system.AddPlanet(bodyPosition, type, size, randomTraits(rng, type, size));
                    bodyPosition++;
                }
            }

            return(Methods.FindWorst(systems, x => Methods.MeanSquareError(
                                         evaluator.StartingScore(x) - startingScore,
                                         evaluator.PotentialScore(x) - potentialScore
                                         )));
        }