public List <DeskSquareModel> FindKnightsPath(FigureModel knightPosition, FigureModel figure, List <FigureModel> friendlyFigures)
        {
            var movesQueue  = new Queue <List <DeskSquareModel> >();
            var visitedList = new List <DeskSquareModel>();

            visitedList.AddRange(friendlyFigures);

            var TheShortestPath = new List <DeskSquareModel>
            {
                knightPosition
            };

            movesQueue.Enqueue(TheShortestPath);

            while (movesQueue.Count != 0)
            {
                List <DeskSquareModel> currentPath   = movesQueue.Dequeue();
                DeskSquareModel        currentSquare = currentPath.Last();

                if ((currentSquare.X == figure.X) && (currentSquare.Y == figure.Y))
                {
                    return(currentPath);
                }

                var allPossibleMoves = GetAllKnightMoves(currentSquare);
                foreach (var nearSquare in allPossibleMoves)
                {
                    if (!visitedList.Any(x => x.X == nearSquare.X && x.Y == nearSquare.Y))
                    {
                        var moves = new List <DeskSquareModel>();
                        moves.AddRange(currentPath);
                        moves.Add(nearSquare);

                        visitedList.Add(nearSquare);

                        movesQueue.Enqueue(currentPath);
                        movesQueue.Enqueue(moves);
                    }
                }
            }

            //No way in here to capture all the figures, returning empty list.
            return(new List <DeskSquareModel>());
        }
        private List <DeskSquareModel> GetAllKnightMoves(DeskSquareModel square)
        {
            var possiblePositions = new List <DeskSquareModel>();

            foreach (var move in KnightMoves)
            {
                var x = move.Item1;
                var y = move.Item2;

                var newX = move.Item1 + square.X;
                var newY = move.Item2 + square.Y;

                if (FigureBehavior.IsValidCoordinates(newX, newY))
                {
                    possiblePositions.Add(new DeskSquareModel()
                    {
                        X = newX, Y = newY
                    });
                }
            }
            return(possiblePositions);
        }