Exemple #1
0
        /// <summary>
        /// Creates a finished map (placing cliffs, smoothing them, turning/mirroring the map, etc.)
        /// </summary>
        /// <param name="half"> The half to work on. </param>
        /// <param name="function"> The way to create the complete map. </param>
        /// <returns> The finished map. </returns>
        public MapPhenotype CreateFinishedMap(Half half, Enums.MapFunction function)
        {
            var tempMap = this.CreateCompleteMap(half, function);

            tempMap.PlaceCliffs();
            tempMap.SmoothCliffs();
            tempMap = tempMap.CreateCompleteMap(half, function);
            return(tempMap);
        }
Exemple #2
0
        /// <summary>
        /// Creates a map where one part has been turned onto the other part of the map.
        /// </summary>
        /// <param name="half"> The half to work on. </param>
        /// <param name="function"> The way to create the complete map. </param>
        /// <returns> The complete map. </returns>
        public MapPhenotype CreateCompleteMap(Half half, Enums.MapFunction function)
        {
            this.mapHalf = half;

            var newHeightLevels = (HeightLevel[, ]) this.HeightLevels.Clone();
            var newMapItems     = (Item[, ]) this.MapItems.Clone();
            var rocks           = (bool[, ]) this.DestructibleRocks.Clone();

            // Figures out which part of the map that should be looked at.
            var xStart = (half == Half.Right) ? this.XSize / 2 : 0;
            var xEnd   = (half == Half.Left) ? this.XSize / 2 : this.XSize;
            var yStart = (half == Half.Top) ? this.YSize / 2 : 0;
            var yEnd   = (half == Half.Bottom) ? this.YSize / 2 : this.YSize;

            for (var y = yStart; y < yEnd; y++)
            {
                var otherY = y;

                // If we mirror top or bottom or turn the map, find the height to copy to.
                if ((function == Enums.MapFunction.Mirror && (half == Half.Top || half == Half.Bottom)) ||
                    function == Enums.MapFunction.Turn)
                {
                    otherY = this.YSize - y - 1;
                }

                for (var x = xStart; x < xEnd; x++)
                {
                    var otherX = x;

                    // If we mirror left or right or turn the map, find the width to copy to.
                    if ((function == Enums.MapFunction.Mirror && (half == Half.Left || half == Half.Right)) ||
                        function == Enums.MapFunction.Turn)
                    {
                        otherX = this.XSize - x - 1;
                    }

                    newHeightLevels[otherX, otherY] = this.HeightLevels[x, y];
                    newMapItems[otherX, otherY]     = this.MapItems[x, y];
                    rocks[otherX, otherY]           = this.DestructibleRocks[x, y];
                }
            }

            var newMap = new MapPhenotype(newHeightLevels, newMapItems, rocks);

            return(newMap);
        }
Exemple #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MapSearchOptions"/> class.
 /// </summary>
 /// <param name="mp"> The map phenotype to search on. </param>
 /// <param name="mapCompletion"> The completion method to use when converting to phenotype. </param>
 /// <param name="chanceToAddBase"> The chance To Add Base. </param>
 /// <param name="chanceToAddGoldBase"> The chance To Add Gold Base. </param>
 /// <param name="chanceToAddXelNagaTower"> The chance To Add Xel'Naga Tower. </param>
 /// <param name="chanceToAddDestructibleRocks"> The chance To Add Destructible Rocks. </param>
 /// <param name="chanceToAddNewElement"> The chance that an element will be added to a solution during mutation. </param>
 /// <param name="chanceToRemoveElement"> The chance that an element will be removed from a solution during mutation. </param>
 /// <param name="maximumDisplacement"> The maximum Displacement. </param>
 /// <param name="displacementAmountPerStep"> The displacement Amount Per Step. </param>
 /// <param name="tooFewElementsPenalty"> The element Not Placed Penalty. </param>
 /// <param name="tooManyElementsPenalty"> The too Many Elements Penalty. </param>
 /// <param name="noPathBetweenStartBasesPenalty"> The penalty to apply to map phenotypes that do not have a path between starting bases. </param>
 /// <param name="notPlacedPenalty"> The amount to add to the distance when a map point was not placed during conversion.  </param>
 /// <param name="notPlacedPenaltyModifier"> The amount to modify the distance of angle/distance when a map point was not placed during conversion. </param>
 /// <param name="minimumStartBaseDistance"> The minimum Start Base Distance. </param>
 /// <param name="maximumStartBaseDistance"> The maximum Start Base Distance. </param>
 /// <param name="maximumDegree"> The maximum Degree. </param>
 /// <param name="minimumDegree"> The minimum Degree. </param>
 /// <param name="maximumDistance"> The maximum Distance. </param>
 /// <param name="minimumDistance"> The minimum Distance. </param>
 /// <param name="maximumDistanceModifier"> The maximum Distance Modifier. </param>
 /// <param name="minimumDistanceModifier"> The minimum Distance Modifier. </param>
 /// <param name="maximumDegreeModifier"> The maximum Degree Modifier. </param>
 /// <param name="minimumDegreeModifier"> The minimum Degree Modifier. </param>
 /// <param name="minimumNumberOfBases"> The minimum Number Of Bases. </param>
 /// <param name="maximumNumberOfBases"> The maximum Number Of Bases. </param>
 /// <param name="minimumNumberOfRamps"> The minimum Number Of Ramps. </param>
 /// <param name="maximumNumberOfRamps"> The maximum Number Of Ramps. </param>
 /// <param name="minimumNumberOfDestructibleRocks"> The minimum Number Of Destructible Rocks. </param>
 /// <param name="maximumNumberOfDestructibleRocks"> The maximum Number Of Destructible Rocks. </param>
 /// <param name="minimumNumberOfXelNagaTowers"> The minimum Number Of Xel'Naga Towers. </param>
 /// <param name="maximumNumberOfXelNagaTowers"> The maximum Number Of Xel'Naga Towers. </param>
 public MapSearchOptions(
     MapPhenotype mp,
     Enums.MapFunction mapCompletion       = Enums.MapFunction.Turn,
     double chanceToAddBase                = 0.15,
     double chanceToAddGoldBase            = 0.05,
     double chanceToAddXelNagaTower        = 0.05,
     double chanceToAddDestructibleRocks   = 0.45,
     double chanceToAddNewElement          = 0.3,
     double chanceToRemoveElement          = 0.3,
     int maximumDisplacement               = 10,
     int displacementAmountPerStep         = 1,
     double tooFewElementsPenalty          = 5,
     double tooManyElementsPenalty         = 5,
     double noPathBetweenStartBasesPenalty = 100,
     double notPlacedPenalty               = 10,
     double notPlacedPenaltyModifier       = 1.5,
     double minimumStartBaseDistance       = 0.4,
     double maximumStartBaseDistance       = 0.9,
     double maximumDegree                 = 180,
     double minimumDegree                 = 0,
     double maximumDistance               = 1.0,
     double minimumDistance               = 0.15,
     double maximumDistanceModifier       = 0.1,
     double minimumDistanceModifier       = 0.01,
     double maximumDegreeModifier         = 20,
     double minimumDegreeModifier         = 1,
     int minimumNumberOfBases             = 1,
     int maximumNumberOfBases             = 5,
     int minimumNumberOfRamps             = 6,
     int maximumNumberOfRamps             = 18,
     int minimumNumberOfDestructibleRocks = 4,
     int maximumNumberOfDestructibleRocks = 8,
     int minimumNumberOfXelNagaTowers     = 1,
     int maximumNumberOfXelNagaTowers     = 1)
 {
     this.ChanceToAddBase                = chanceToAddBase;
     this.ChanceToAddXelNagaTower        = chanceToAddXelNagaTower;
     this.ChanceToAddDestructibleRocks   = chanceToAddDestructibleRocks;
     this.ChanceToAddGoldBase            = chanceToAddGoldBase;
     this.ChanceToRemoveElement          = chanceToRemoveElement;
     this.ChanceToAddNewElement          = chanceToAddNewElement;
     this.MaximumStartBaseDistance       = maximumStartBaseDistance;
     this.MinimumStartBaseDistance       = minimumStartBaseDistance;
     this.TooManyElementsPenalty         = tooManyElementsPenalty;
     this.TooFewElementsPenalty          = tooFewElementsPenalty;
     this.DisplacementAmountPerStep      = displacementAmountPerStep;
     this.MaximumDisplacement            = maximumDisplacement;
     this.NoPathBetweenStartBasesPenalty = noPathBetweenStartBasesPenalty;
     this.MapCompletion = mapCompletion;
     this.MaximumNumberOfXelNagaTowers     = maximumNumberOfXelNagaTowers;
     this.MinimumNumberOfXelNagaTowers     = minimumNumberOfXelNagaTowers;
     this.MaximumNumberOfDestructibleRocks = maximumNumberOfDestructibleRocks;
     this.MinimumNumberOfDestructibleRocks = minimumNumberOfDestructibleRocks;
     this.MaximumNumberOfRamps             = maximumNumberOfRamps;
     this.MinimumNumberOfRamps             = minimumNumberOfRamps;
     this.MaximumNumberOfBases             = maximumNumberOfBases;
     this.MinimumNumberOfBases             = minimumNumberOfBases;
     this.MinimumDegreeModifier            = minimumDegreeModifier;
     this.MaximumDegreeModifier            = maximumDegreeModifier;
     this.MinimumDistanceModifier          = minimumDistanceModifier;
     this.MaximumDistanceModifier          = maximumDistanceModifier;
     this.MinimumDistance          = minimumDistance;
     this.MaximumDistance          = maximumDistance;
     this.MinimumDegree            = minimumDegree;
     this.MaximumDegree            = maximumDegree;
     this.NotPlacedPenalty         = notPlacedPenalty;
     this.NotPlacedPenaltyModifier = notPlacedPenaltyModifier;
     this.Map = mp;
 }