YPosition

We found 10 examples in language CSharp for this search. You will see 39 fragments of code.

Other methods

    public int[] GetArea(int xPosition,int yPosition,int power) //return x1,y1,x2,y2 in array
    {
        int[] temp = new int[4];
        temp[0] = getVTop(xPosition, yPosition, power, 1);
        temp[1] = getVBottom(xPosition, yPosition, power, 1);
        temp[2] = getHLeft(xPosition, yPosition, power, 1);
        temp[3] = getHRight(xPosition, yPosition, power, 1);
        return temp;
    }


		public bool CanAddMove (TTTMoveXPosition xPosition, TTTMoveYPosition yPosition)
		{
			if (Result != TTTGameResult.InProgress)
				return false;

			TTTMovePlayer player = TTTMovePlayer.None;

			return !hasMove (xPosition, yPosition, ref player);
		}

		public void AddMove (TTTMoveXPosition xPosition, TTTMoveYPosition yPosition)
		{
			if (!CanAddMove (xPosition, yPosition))
				return;

			TTTMove move = new TTTMove (currentPlayer, xPosition, yPosition);
			Moves.Add (move);

			currentPlayer = currentPlayer == TTTMovePlayer.Me ?
				TTTMovePlayer.Enemy : TTTMovePlayer.Me;

			updateGameResult ();
		}

		bool hasMove (TTTMoveXPosition xPosition, TTTMoveYPosition yPosition,
		              ref TTTMovePlayer player)
		{
			foreach (var move in Moves) {
				if (move.XPosition == xPosition && move.YPosition == yPosition) {
					player = move.Player;

					return true;
				}
			}
			return false;
		}


        public int GetYposition()
        {
            return yPosition;
        }

        public void MoveUp() {
            previousYposition = yPosition;
            if (yPosition > 0)
            {
                yPosition = yPosition - movementLength;
            }
            
        }

        public void MoveDown() {
            previousYposition = yPosition;
            if (yPosition < worldHeight - Height)
            {
                yPosition = yPosition + movementLength;
            }
        }

        public int YCenterOfBar()
        {
            return yPosition + Height/2;
        }


        public double Length()
        {
            double length = Math.Sqrt((Math.Pow(XPosition, 2) + Math.Pow(YPosition, 2)));
            return length;
        }

        public bool Equals(Position p)
        {
            return (p.XPosition == XPosition && p.YPosition == YPosition);
        }

        public Position Clone()
        {
            return new Position(XPosition, YPosition);
        }

        public override string ToString()
        {
            return "(" + XPosition + "," + YPosition + ")";
        }

    public int CheckingNeighbors(int xPosition, int yPosition)
    {
        countVisited = 0;
        GetVisitedNeighbor(xPosition + 1, yPosition, xPosition + 1 < width);
        GetVisitedNeighbor(xPosition, yPosition - 1, yPosition - 1 >= 0);
        GetVisitedNeighbor(xPosition - 1, yPosition, xPosition - 1 >= 0);
        GetVisitedNeighbor(xPosition, yPosition + 1, yPosition + 1 < height);
        return countVisited;
    }

    public void GetVisitedNeighbor(int xPosition, int yPosition, bool condition)
    {
        mazeGenerator = GetComponent<MazeGenerator>();
        if (condition)
        {
            if (mazeGenerator.mazeCells[xPosition, yPosition].Visited == true)
                countVisited++;
        }
    }

    public void GetNeighborWeight(int xPosition, int yPosition)
    {
        GetWeight(xPosition + 1, yPosition, xPosition + 1 < width);
        GetWeight(xPosition, yPosition - 1, yPosition - 1 >= 0);
        GetWeight(xPosition - 1, yPosition, xPosition - 1 >= 0);
        GetWeight(xPosition, yPosition + 1, yPosition + 1 < height);
    }


		public bool CanAddMove (TTTMoveXPosition xPosition, TTTMoveYPosition yPosition)
		{
			if (Result != TTTGameResult.InProgress)
				return false;

			TTTMovePlayer player = TTTMovePlayer.None;

			return !hasMove (xPosition, yPosition, ref player);
		}

		public void AddMove (TTTMoveXPosition xPosition, TTTMoveYPosition yPosition)
		{
			if (!CanAddMove (xPosition, yPosition))
				return;

			TTTMove move = new TTTMove (currentPlayer, xPosition, yPosition);
			Moves.Add (move);

			currentPlayer = currentPlayer == TTTMovePlayer.Me ?
				TTTMovePlayer.Enemy : TTTMovePlayer.Me;

			updateGameResult ();
		}

		bool hasMove (TTTMoveXPosition xPosition, TTTMoveYPosition yPosition,
		              ref TTTMovePlayer player)
		{
			foreach (var move in Moves) {
				if (move.XPosition == xPosition && move.YPosition == yPosition) {
					player = move.Player;

					return true;
				}
			}
			return false;
		}

/// the numbers of strategy options

        public static Boolean[] strategy(string strategyNumber, Maze maze, Actor actor, int yPosition, int xPosition, int count) ///strategy public static interface, takes the arguments for the selected strategy                                                                                                                        ///and calls the apropriate private mathod of the given strategy 
        {
            Boolean[] Result = new bool[2] { false, false };///stores the results of the chosen strategy

            if (strategyNumber == "1")///runs the given method with correct arguments and returns a boolean array with its results
            { Result[1] = strategy1(maze, actor, yPosition, xPosition); }
            else if (strategyNumber == "2")
            { Result = strategy2(maze, actor, yPosition, xPosition, count); }
            return Result;
        }

        
        /*The strategy method takes as parameters the Maze object the Actor object, and the present position, and implements 
         a recursive algorithm that traverses the Maze, updates Actors map of the Maze, and when reaches the Exit,
         it Bubbles up to the surface...to the first caller instance of the method, marking the Exit path.
         
         The Algorithm was heavily inspired from "http://interactivepython.org/runestone/static/pythonds/Recursion/ExploringaMaze.html" 
         
         The Algorithm's efficiency depends largely, on the order that the various branches (up,down.left.right)
         are executed and prioritized, The direction that executes first marks first it's path as visited, and blocks the 
         execution of other, possible, sortest branches*/

        private static bool strategy1(Maze maze, Actor actor, int yPosition, int xPosition)

        {
            if (maze.ask(yPosition, xPosition) == "X")///ask maze if the current square is blocked 
            {
                return false;///then if it is blocked return with false to the caller method
            }
            else if (maze.ask(yPosition, xPosition) == "OOM")///Out Of Maze square
            {

                return false;
            }
            else if (maze.ask(yPosition, xPosition) == "EXIT")///if it is the exit!!!!!
            {
                actor.exitPath.Push((yPosition + 1).ToString() + "," + (xPosition + 1).ToString());///push it to the Exit Path stack!
                actor.writeMap(yPosition, xPosition, "EXIT");///  update actors map
                return true;  ///  bubble up a true boolean to the caller and mark the exit path
            }
            else if (actor.readMap(yPosition, xPosition) == "VISITED")///if was visited before
            {
                return false;
            }
            else
            { actor.writeMap(yPosition, xPosition, "VISITED"); }///mark the square as visited, 
                                                                ///cause if not no memory of past actions, and infinity!

            ///Check recursively using the same method for exit in paths that start from the square 
            ///that lies down or right or up or left of current position, and return true if an Exit path is found

            bool Exit = strategy1(maze, actor, yPosition + 1, xPosition)
                          || strategy1(maze, actor, yPosition, xPosition + 1)
                          || strategy1(maze, actor, yPosition - 1, xPosition)
                          || strategy1(maze, actor, yPosition, xPosition - 1);

            if (Exit)
            {
                actor.writeMap(yPosition, xPosition, "EXITPATH");///if the path started from here, leads to an exit then mark the exit path
                actor.exitPath.Push((yPosition + 1).ToString() + "," + (xPosition + 1).ToString());///push it to the Exit Path stack!

            }
            else
            {
                actor.writeMap(yPosition, xPosition, "DEADEND"); ///if not, mark the square as dead end path
            }

            return Exit;/// return to the caller function if this is an EXIT path.
        }

        /*This strategy method is similar to the above with the addition of a counter that marks the depth of the recursion path, in every visited square, so it gives 
         a chance to revisit squares if the new path is shorter in depth, and also when it calls itself in  neighbouring squares it uses a non shotcircuited OR " | " that 
         makes sure that all possible branches execute. finally, when a branch reaches the exit point, if it is shortest, than another branch that reached it first , then it clears the
         exit path stack (kept in actor object), and it marks the new shortest exit path as it bubbles up as true
         
         The aforementioned "improvements" were mine contributions, the algorithm finds the shortest path, but the search is tremendously slow in
         bigger mazes,"don't try maze 4!!!"*/

        private static bool[] strategy2(Maze maze, Actor actor, int yPosition, int xPosition, int count)
        {
            count += 1;///counter to know the recursive depth

            if (maze.ask(yPosition, xPosition) == "X")///ask maze if the current square is blocked 
            {

                return new Boolean[] { false, false };///then if it is blocked return with false to the caller method
            }
            else if (maze.ask(yPosition, xPosition) == "OOM")///Out Of Maze square
            {

                return new Boolean[] { false, false };///return no exit path mark
            }
            else if (actor.readMap(yPosition, xPosition) == "DEADEND")///DeadEnd
            {

                return new Boolean[] { false, false };
            }

            else if (maze.ask(yPosition, xPosition) == "EXIT")///if it is the exit!!!!!
            {

                if (actor.mapWithCounts[yPosition, xPosition] <= count && actor.mapWithCounts[yPosition, xPosition] != 0)///if there is another exitpath but it is shortert that current branch depth (count)

                {
                    return new Boolean[] { true, false };///then return [true false], the first boolean that we got an exit path, but the second one states that the current is not the shortest.
                }
                else///we found the exit square and in fewer steps than the previous path
                {
                    actor.exitPath.Clear();///we clear the exit path stack "the previous shortest path"
                    actor.writeMap(0, 0, "CLEARPATH");///we update the actors map "notes", so to clear from there too, the exit path
                    actor.mapWithCounts[yPosition, xPosition] = count;///updates the depth of the current(shortest) path to the exit square at the actors note
                    actor.exitPath.Push((yPosition + 1).ToString() + "," + (xPosition + 1).ToString());///push it to the Exit Path stack!
                    actor.writeMap(yPosition, xPosition, "EXIT");///  update actors map
                    return new Boolean[] { true, true };///returns 2 booleans first true that we have an exit, second true that is currently the shoertest one 
                }///  bubble up a true boolean to the caller and mark the exit path
            }

            else if (actor.mapWithCounts[yPosition, xPosition] != 0) ///if was visited before
            {
                if (count > actor.mapWithCounts[yPosition, xPosition])
                    return new Boolean[] { false, false };
            }
            else
            { actor.mapWithCounts[yPosition, xPosition] = count; }///mark the square as visited, 
                                                                  ///cause if not no memory of past actions, and infinity!

            ///Check recursively using the same method for exit in paths that start from the square 
            ///that lies down or right or up or left of current position, and return true if an Exit path is found

            bool[] resultUp = strategy2(maze, actor, yPosition - 1, xPosition, count);
            bool[] resultRight = strategy2(maze, actor, yPosition, xPosition + 1, count);
            bool[] resultDown = strategy2(maze, actor, yPosition + 1, xPosition, count);
            bool[] resultLeft = strategy2(maze, actor, yPosition, xPosition - 1, count);

            if (resultUp[1] || resultRight[1] || resultDown[1] || resultLeft[1])///if a shortest exit path was found to the branches started from here
            {
                actor.writeMap(yPosition, xPosition, "EXITPATH");/// mark the current square as part of the exit path
                actor.exitPath.Push((yPosition + 1).ToString() + "," + (xPosition + 1).ToString());///push it to the Exit Path stack!

                return new Boolean[] { true, true };///return to the caller function with a sign of a shortest exit path found
            }
            else if (resultUp[0] || resultRight[0] || resultDown[0] || resultLeft[0])///if it there is an exit path in one direction, but it is'not the shortest
            {
                return new Boolean[] { true, false };

            }
            else
            {///if there is no exit path all the way around(the square that we came from gives false because of depth counter)

                actor.writeMap(yPosition, xPosition, "DEADEND");///then mark this square as dead end
                return new Boolean[] { false, false };///and return no exit path mark
            }



        }


        [SetUp]
        public void Init()
        {
            controller = new();
            Model.RoverInfo.ListOfAllRovers.Clear();
        }

        /// <summary>
        /// Test checks whether a plateau can be initialised
        /// </summary>
        [Test]
        public void SetUpperLimitsPlateau()
        {
            int upperLimitX = 7;
            int upperLimitY = 8;

            Model.Plateau.UpperRightCoordinates = null;
            controller.ProcessUserInput(upperLimitX + " " + upperLimitY);


            Assert.IsTrue(
                Model.Plateau.UpperRightCoordinates[0, 0] == upperLimitX &&
                Model.Plateau.UpperRightCoordinates[0, 1] == upperLimitY
                );
        }

        /// <summary>
        /// Test checks whether the rover can be created
        /// Test checks whether the created rover has correct X, Y positions and correct orientation
        /// </summary>
        [Test]
        public void SetRoverLocation()
        {
            int roverXPosition = 1;
            int roverYPosition = 3;
            string roverOrientation = "W";

            controller.ProcessUserInput(roverXPosition + " " + roverYPosition + " " + roverOrientation);


            Rover lastRover = RoverInfo.ListOfAllRovers[^1];

            Assert.IsTrue(
                lastRover.X == roverXPosition &&
                lastRover.Y == roverYPosition &&
                lastRover.Orientation.ToString() == roverOrientation
                );
        }


        /// <summary>
        /// Test checks whether new rover can be created and successfully rotated left.
        /// </summary>
        [Test]
        public void Spin90DegreesLeft()
        {
            int roverXPosition = 1;
            int roverYPosition = 4;
            string roverOrientation = "W";

            controller.ProcessUserInput(roverXPosition + " " + roverYPosition + " " + roverOrientation);

            controller.ProcessUserInput("L");

            Rover lastRover = RoverInfo.ListOfAllRovers[^1];

            Assert.IsTrue(
                lastRover.X == roverXPosition &&
                lastRover.Y == roverYPosition &&
                lastRover.Orientation.ToString() == "S"
                );

        }

        /// <summary>
        /// Test checks whether new rover can be created and successfully rotated right.
        /// </summary>
        [Test]
        public void Spin90DegreesRight()
        {
            int roverXPosition = 1;
            int roverYPosition = 5;
            string roverOrientation = "W";

            controller.ProcessUserInput(roverXPosition + " " + roverYPosition + " " + roverOrientation);

            controller.ProcessUserInput("R");

            Rover lastRover = RoverInfo.ListOfAllRovers[^1];

            Assert.IsTrue(
                lastRover.X == roverXPosition &&
                lastRover.Y == roverYPosition &&
                lastRover.Orientation.ToString() == "N"
                );
        }

        /// <summary>
        /// Test checks whether a rover can be created and moved
        /// </summary>
        [Test]
        public void RoverMove()
        {
            int roverXPosition = 2;
            int roverYPosition = 2;
            string roverOrientation = "N";

            controller.ProcessUserInput(roverXPosition + " " + roverYPosition + " " + roverOrientation);
            controller.ProcessUserInput("M");


            Rover lastRover = RoverInfo.ListOfAllRovers[^1];

            Assert.IsTrue(
                lastRover.X == roverXPosition &&
                lastRover.Y == (roverYPosition + 1) &&
                lastRover.Orientation.ToString() == "N"
                );
        }


        public void AddHeaderLine(string line)
        {
            headerLines.Add(line);
        }

        public void AddSubHeaderLine(string line)
        {
            subHeaderLines.Add(line);
        }

        public void AddItem(string cantidad, string item, string singlePrice, string cost)
        {
            OrderItem newItem = new OrderItem('?');
            items.Add(newItem.GenerateItem(cantidad, item, singlePrice, cost));
        }

        public void AddTotal(string name, string price)
        {
            OrderTotal newTotal = new OrderTotal('?');
            totales.Add(newTotal.GenerateTotal(name, price));
        }

        public void AddFooterLine(string line)
        {
            footerLines.Add(line);
        }

        private string AlignRightText(int lenght)
        {
            string espacios = "";
            int spaces = maxChar - lenght;
            for (int x = 0; x < spaces; x++)
                espacios += " ";
            return espacios;
        }


            public bool Equals(Dot otherDot) {
                return xPosition == otherDot.xPosition && yPosition == otherDot.yPosition;
            }

            public static Dot Translate(Dot oldDot, int xTranslation, int yTranslation) {
                return new Dot(oldDot.xPosition + xTranslation, oldDot.yPosition + yTranslation);
            }

            public static Dot FoldAlongXAxis(Dot oldDot, int yAxisOffset) {
                Dot newDot = new Dot(oldDot.xPosition, oldDot.yPosition);
                newDot = Translate(newDot, 0, -yAxisOffset);

                if (newDot.yPosition > 0) {
                    newDot.yPosition = -newDot.yPosition;
                }

                newDot = Translate(newDot, 0, yAxisOffset);

                return newDot;
            }

            public static Dot FoldAlongYAxis(Dot oldDot, int xAxisOffset) {
                Dot newDot = new Dot(oldDot.xPosition, oldDot.yPosition);
                newDot = Translate(newDot, -xAxisOffset, 0);

                if (newDot.xPosition > 0) {
                    newDot.xPosition = -newDot.xPosition;
                }

                newDot = Translate(newDot, xAxisOffset, 0);

                return newDot;
            }
        static void Main(string[] args) {
            string filePath = @"C:\Users\Enhander\Documents\Programming\Advent of Code\2021\Day 13\Part1Input.txt";
            List<string> input = LoadInput(filePath);

            List<Instruction> instructions;
            List<Dot> dots = GetDotsAndInstructions(input, out instructions);

            dots = ExecuteInstructions(dots, instructions);
            PrintFoldedDots(dots);
        }

        public static List<string> LoadInput(string filePath) {
            StreamReader streamReader = new StreamReader(filePath);
            List<string> input = new List<string>();

            string nextLine;
            while ((nextLine = streamReader.ReadLine()) != null) {
                input.Add(nextLine);
            }

            return input;
        }

DocumentFormat.OpenXml.Drawing.ChartDrawing.YPosition : IEnumerable

Constructors :

public YPosition()
public YPosition(String text = )

Methods :

public OpenXmlElement CloneNode(Boolean deep = )
public Boolean get_HasChildren()
public String get_InnerText()
public String get_InnerXml()
public Void set_InnerXml(String value = )
public String get_Text()
public Void set_Text(String value = )
public Void RemoveAllChildren()
public T ReplaceChild(OpenXmlElement newChild = , T oldChild = )
public Void RemoveAllChildren()
public Void Remove()
public Boolean IsAfter(OpenXmlElement element = )
public Boolean IsBefore(OpenXmlElement element = )
public Void AddAnnotation(Object annotation = )
public T Annotation()
public Object Annotation(Type type = )
public IEnumerable<T> Annotations()
public IEnumerable<Object> Annotations(Type type = )
public Void RemoveAnnotations()
public Void RemoveAnnotations(Type type = )
public IEnumerator<OpenXmlElement> GetEnumerator()
public Object Clone()
public MarkupCompatibilityAttributes get_MCAttributes()
public Void set_MCAttributes(MarkupCompatibilityAttributes value = )
public String LookupNamespace(String prefix = )
public String LookupPrefix(String namespaceUri = )
public IFeatureCollection get_Features()
public OpenXmlElementContext get_OpenXmlElementContext()
public OpenXmlElement get_FirstChild()
public OpenXmlElement get_LastChild()
public Boolean get_HasAttributes()
public IEnumerable<OpenXmlAttribute> get_ExtendedAttributes()
public OpenXmlElementList get_ChildElements()
public OpenXmlElement get_Parent()
public String get_NamespaceUri()
public String get_LocalName()
public String get_Prefix()
public IEnumerable<KeyValuePair<StringString>> get_NamespaceDeclarations()
public XmlQualifiedName get_XmlQualifiedName()
public XName get_XName()
public String get_OuterXml()
public OpenXmlAttribute GetAttribute(String localName = , String namespaceUri = )
public IList<OpenXmlAttribute> GetAttributes()
public Void SetAttribute(OpenXmlAttribute openXmlAttribute = )
public Void RemoveAttribute(String localName = , String namespaceUri = )
public Void SetAttributes(IEnumerable<OpenXmlAttribute> openXmlAttributes = )
public Void ClearAllAttributes()
public Void AddNamespaceDeclaration(String prefix = , String uri = )
public Void RemoveNamespaceDeclaration(String prefix = )
public T GetFirstChild()
public OpenXmlElement PreviousSibling()
public T PreviousSibling()
public OpenXmlElement NextSibling()
public T NextSibling()
public IEnumerable<OpenXmlElement> Ancestors()
public IEnumerable<T> Ancestors()
public IEnumerable<T> Elements()
public IEnumerable<OpenXmlElement> Elements()
public IEnumerable<T> Descendants()
public IEnumerable<OpenXmlElement> Descendants()
public IEnumerable<OpenXmlElement> ElementsBefore()
public IEnumerable<OpenXmlElement> ElementsAfter()
public Void WriteTo(XmlWriter xmlWriter = )
public Void Append(IEnumerable<OpenXmlElement> newChildren = )
public Void Append(OpenXmlElement[] newChildren = )
public T AppendChild(T newChild = )
public T InsertAfter(T newChild = , OpenXmlElement referenceChild = )
public T InsertBefore(T newChild = , OpenXmlElement referenceChild = )
public T InsertAfterSelf(T newElement = )
public T InsertBeforeSelf(T newElement = )
public T InsertAt(T newChild = , Int32 index = )
public T PrependChild(T newChild = )
public T RemoveChild(T oldChild = )
public Type GetType()
public String ToString()
public Boolean Equals(Object obj = )
public Int32 GetHashCode()