Esempio n. 1
0
        /// <summary>
        ///     ...Description to be added...
        /// </summary>
        public Point Point(ElementPoint point)
        {
            switch (point)
            {
            case ElementPoint.TopLeftPoint:
                return(TopLeftPoint);

            case ElementPoint.MiddleLeftPoint:
                return(MiddleLeftPoint);

            case ElementPoint.BottomLeftPoint:
                return(BottomLeftPoint);

            case ElementPoint.TopMiddlePoint:
                return(TopMiddlePoint);

            case ElementPoint.MiddlePoint:
                return(MiddlePoint);

            case ElementPoint.BottomMiddlePoint:
                return(BottomMiddlePoint);

            case ElementPoint.TopRightPoint:
                return(TopRightPoint);

            case ElementPoint.MiddleRightPoint:
                return(MiddleRightPoint);

            case ElementPoint.BottomRightPoint:
                return(BottomRightPoint);

            default:
                throw new InvalidEnumArgumentException();
            }
        }
Esempio n. 2
0
        private static void AppendToStreamGrowth(int[,,] etherResistanceEnvironment, HashSet <ElementPoint> streamPath, HashSet <EtherStreamGrowthDirection> streamGrowth, ElementPoint growthPoint, out int totalWeights)
        {
            totalWeights = 0;

            ElementPoint[] directionalPoints = new ElementPoint[]
            {
                growthPoint.CloneWithOffset(1, 0, 0),
                growthPoint.CloneWithOffset(0, 1, 0),
                growthPoint.CloneWithOffset(0, 0, 1),
                growthPoint.CloneWithOffset(-1, 0, 0),
                growthPoint.CloneWithOffset(0, -1, 0),
                growthPoint.CloneWithOffset(0, 0, -1)
            };

            foreach (ElementPoint directionalPoint in directionalPoints)
            {
                if (!streamPath.Contains(directionalPoint) && etherResistanceEnvironment.WithinBounds(directionalPoint))
                {
                    int directionalWeight = etherResistanceEnvironment.AtPoint(growthPoint) - etherResistanceEnvironment.AtPoint(directionalPoint) + 1;
                    if (directionalWeight > 0)
                    {
                        streamGrowth.Add(new EtherStreamGrowthDirection()
                        {
                            From = growthPoint, To = directionalPoint, Weight = directionalWeight
                        });
                        totalWeights += directionalWeight;
                    }
                }
            }
        }
Esempio n. 3
0
        public EtherVM(ElementPoint size, int[,,] environment)
        {
            Size         = size;
            _environment = environment;

            timeTickButton.Click  += OnTimeTickButton_Click;
            resetTimeButton.Click += OnResetTimeButton_Click;
        }
Esempio n. 4
0
        /// <summary>
        ///     ...Description to be added...
        /// </summary>
        /// <param name="toElement">...Description to be added...</param>
        /// <param name="toElementPoint">...Description to be added...</param>
        public ExtendedActions MoveToElement([NotNull] IWebElement toElement, ElementPoint toElementPoint)
        {
            if (toElement == null)
            {
                throw new ArgumentNullException(nameof(toElement));
            }

            return(MoveTo(toElement.Location().Point(toElementPoint)));
        }
Esempio n. 5
0
        /// <summary>
        ///     ...Description to be added...
        /// </summary>
        /// <param name="onElement">...Description to be added...</param>
        /// <param name="elementPoint">...Description to be added...</param>
        public ExtendedActions Click([NotNull] IWebElement onElement, ElementPoint elementPoint)
        {
            if (onElement == null)
            {
                throw new ArgumentNullException(nameof(onElement));
            }

            MoveToElement(onElement, elementPoint);
            Click(onElement);
            return(this);
        }
        public static bool WithinBounds <T>(this T[,,] environment, ElementPoint point)
        {
            if (point.waterPosition < 0 || point.woodPosition < 0 || point.windPosition < 0)
            {
                return(false);
            }

            if (point.waterPosition > environment.GetUpperBound(0) || point.woodPosition > environment.GetUpperBound(1) || point.windPosition > environment.GetUpperBound(2))
            {
                return(false);
            }

            return(true);
        }
Esempio n. 7
0
        private static ElementPoint ChooseNewGrowthBud(HashSet <ElementPoint> streamPath, Random rand)
        {
            int          choice    = rand.Next(streamPath.Count) + 1;
            ElementPoint growthBud = null;

            foreach (ElementPoint streamPoint in streamPath)
            {
                if (--choice == 0)
                {
                    growthBud = streamPoint;
                    break;
                }
            }
            return(growthBud);
        }
Esempio n. 8
0
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }
            if (!(obj is ElementPoint))
            {
                return(false);
            }

            ElementPoint that = (ElementPoint)obj;

            return(that.X == this.X && that.Y == this.Y && that.Element == this.Element);
        }
Esempio n. 9
0
        public LabelLineElement(XElement element) : base(element)
        {
            _elementType = ElementType.Line;
            if (element.Name.ToString() == "cutline")
            {
                _linetype = LineType.CutLine;
            }
            else
            {
                _linetype = LineType.FoldLine;
            }
            var points = element.Elements("point");

            if (points != null && points.Count() == 2)
            {
                _startpos = GetPoint(points.First());
                _endpos   = GetPoint(points.Last());
            }
        }
Esempio n. 10
0
        public World(int waterSize, int woodSize, int windSize, int maxElementalVariance = 10)
        {
            Size = new ElementPoint()
            {
                waterPosition = waterSize, woodPosition = woodSize, windPosition = windSize
            };
            MaxElementalVariance = maxElementalVariance;

            WaterWorld = new int[waterSize, woodSize, windSize];
            WoodWorld  = new int[waterSize, woodSize, windSize];
            WindWorld  = new int[waterSize, woodSize, windSize];

            RemakeElementalMap();
            WindEarthEnvironment       = WindEarthMaker.Make(waterSize, woodSize, windSize);
            WaterFireEnvironment       = WaterFireMaker.Make(waterSize, woodSize, windSize);
            WoodMetalEnvironment       = WoodMetalMaker.Make(waterSize, woodSize, windSize);
            EtherResistanceEnvironment = EtherResistanceMaker.Make(WindEarthEnvironment, WaterFireEnvironment, WoodMetalEnvironment);
            EtherEnvironment           = EtherMaker.Make(EtherResistanceEnvironment);
        }
 public static void SetPoint <T>(this T[,,] environment, ElementPoint point, T value)
 {
     environment[point.waterPosition, point.woodPosition, point.windPosition] = value;
 }
 public static T AtPoint <T>(this T[,,] environment, ElementPoint point)
 {
     return(environment[point.waterPosition, point.woodPosition, point.windPosition]);
 }
Esempio n. 13
0
 public WoodMetalVM(ElementPoint size, int[,,] environment)
 {
     Size         = size;
     _environment = environment;
 }
Esempio n. 14
0
 public WaterFireVM(ElementPoint size, int[,,] environment)
 {
     Size         = size;
     _environment = environment;
 }
        private static void GrowEarthCrystal(int[,,] earthCrystalEnvironment, int waterSize, int woodSize, int windSize, Random rand)
        {
            int maxEarth = (waterSize - 2) * (woodSize - 2);

            Dictionary <int, int> earthLimits = new Dictionary <int, int>();

            int totalEarth = 0;

            for (int i = 1; i < windSize - 1; i++)
            {
                double fractionAlongWorld = i / (double)(windSize - 1);
                double spinalValue        = SpinalOperations.WorldSpinalValue(fractionAlongWorld, 1.27);
                int    earthLimit         = (int)(maxEarth * spinalValue);
                totalEarth += earthLimit;
                earthLimits.Add(i, earthLimit);
            }

            List <ElementPoint> growthLocations = new List <ElementPoint>();

            for (int wind = 1; wind < (windSize - 1) / 2; wind++)
            {
                for (int wood = 1; wood < woodSize - 1; wood++)
                {
                    for (int water = 1; water < waterSize - 1; water++)
                    {
                        if (EnvironmentMakerOperations.HasNeighborOfValueOrLess(water, wood, wind, -1, earthCrystalEnvironment))
                        {
                            growthLocations.Add(new ElementPoint()
                            {
                                waterPosition = water, woodPosition = wood, windPosition = wind
                            });
                        }
                    }
                }
            }

            while (totalEarth > 0)
            {
                int          numberOfPossibleLocations = growthLocations.Count;
                int          growthChoice = rand.Next(0, numberOfPossibleLocations);
                ElementPoint growthPoint  = growthLocations[growthChoice];

                growthLocations.Remove(growthPoint);
                earthCrystalEnvironment.SetPoint(growthPoint, -1);
                earthLimits[growthPoint.windPosition]--;

                if (earthLimits[growthPoint.windPosition] == 0)
                {
                    growthLocations.RemoveAll((p) => p.windPosition == growthPoint.windPosition);
                }

                totalEarth--;

                int upperLayer = growthPoint.windPosition + 1;
                if (earthLimits.ContainsKey(upperLayer) && earthLimits[upperLayer] != 0)
                {
                    ElementPoint topPoint = growthPoint.CloneWithOffset(0, 1, 0);
                    if (!growthLocations.Contains(topPoint) && earthCrystalEnvironment.WithinBounds(topPoint) && earthCrystalEnvironment.AtPoint(topPoint) == 0)
                    {
                        growthLocations.Add(topPoint);
                    }
                }
                if (earthLimits[growthPoint.windPosition] != 0)
                {
                    ElementPoint rightPoint = growthPoint.CloneWithOffset(1, 0, 0);
                    if (!growthLocations.Contains(rightPoint) && earthCrystalEnvironment.WithinBounds(rightPoint) && earthCrystalEnvironment.AtPoint(rightPoint) == 0)
                    {
                        growthLocations.Add(rightPoint);
                    }

                    ElementPoint forwardPoint = growthPoint.CloneWithOffset(0, 0, 1);
                    if (!growthLocations.Contains(forwardPoint) && earthCrystalEnvironment.WithinBounds(forwardPoint) && earthCrystalEnvironment.AtPoint(forwardPoint) == 0)
                    {
                        growthLocations.Add(forwardPoint);
                    }

                    ElementPoint leftPoint = growthPoint.CloneWithOffset(-1, 0, 0);
                    if (!growthLocations.Contains(leftPoint) && earthCrystalEnvironment.WithinBounds(leftPoint) && earthCrystalEnvironment.AtPoint(leftPoint) == 0)
                    {
                        growthLocations.Add(leftPoint);
                    }

                    ElementPoint backPoint = growthPoint.CloneWithOffset(0, 0, -1);
                    if (!growthLocations.Contains(backPoint) && earthCrystalEnvironment.WithinBounds(backPoint) && earthCrystalEnvironment.AtPoint(backPoint) == 0)
                    {
                        growthLocations.Add(backPoint);
                    }
                }
                int lowerLayer = growthPoint.windPosition - 1;
                if (earthLimits.ContainsKey(lowerLayer) && earthLimits[lowerLayer] != 0)
                {
                    ElementPoint bottomPoint = growthPoint.CloneWithOffset(0, -1, 0);
                    if (!growthLocations.Contains(bottomPoint) && earthCrystalEnvironment.WithinBounds(bottomPoint) && earthCrystalEnvironment.AtPoint(bottomPoint) == 0)
                    {
                        growthLocations.Add(bottomPoint);
                    }
                }
            }
        }
Esempio n. 16
0
 public WindEarthVM(ElementPoint size, int[,,] environment)
 {
     Size         = size;
     _environment = environment;
 }
Esempio n. 17
0
		private PointF GetGraphicsPointFromElementPoint(ElementPoint elementPoint) {
			return new PointF(
				(elementPoint.X - elementPoint.Y) * gridElementSize.Width + originalPoint.X,
				(-elementPoint.X - elementPoint.Y) * gridElementSize.Height + originalPoint.Y);
		}
Esempio n. 18
0
        private static void GrowStream(int[,,] etherResistanceEnvironment, int[,,] streamEnvironment, ElementPoint corner)
        {
            Random rand = new Random();

            int streamLength = 20 * streamEnvironment.GetLength(0);

            ElementPoint newGrowth = corner;

            HashSet <ElementPoint> streamPath = new HashSet <ElementPoint>()
            {
                newGrowth
            };
            HashSet <ElementPoint> validBuds = new HashSet <ElementPoint>()
            {
                newGrowth
            };

            streamEnvironment.SetPoint(newGrowth, streamEnvironment.AtPoint(newGrowth) + 1);

            HashSet <EtherStreamGrowthDirection> streamGrowth = new HashSet <EtherStreamGrowthDirection>();

            ElementPoint growthBud = corner;

            while (streamLength > 0)
            {
                AppendToStreamGrowth(etherResistanceEnvironment, streamPath, streamGrowth, growthBud, out int totalWeights);

                if (streamGrowth.Count == 0)
                {
                    break;
                }

                if (totalWeights == 0)
                {
                    validBuds.Remove(growthBud);
                    streamGrowth.RemoveWhere(direction => direction.To == growthBud);
                    growthBud = ChooseNewGrowthBud(validBuds, rand);
                    continue;
                }

                EtherStreamGrowthDirection growthChoice = null;

                int choice = rand.Next(totalWeights) + 1;
                foreach (EtherStreamGrowthDirection growth in streamGrowth)
                {
                    int growthWeight = growth.Weight;
                    choice -= growthWeight;
                    if (choice <= 0)
                    {
                        growthChoice = growth;
                        break;
                    }
                }

                newGrowth = growthChoice.To;

                streamPath.Add(newGrowth);
                validBuds.Add(newGrowth);

                streamEnvironment.SetPoint(newGrowth, streamEnvironment.AtPoint(newGrowth) + 1);
                streamGrowth.Remove(growthChoice);
                streamGrowth.RemoveWhere(direction => direction.To == newGrowth);

                growthBud = ChooseNewGrowthBud(validBuds, rand);

                streamLength--;
            }
        }
Esempio n. 19
0
 public EtherResistanceVM(ElementPoint size, int[,,] environment)
 {
     Size         = size;
     _environment = environment;
 }