Ejemplo n.º 1
0
        private static string FindPath(Point from, Point to)
        {
            string path = to.ToString() + "\"]";

            while (!from.Equals(to))
            {
                List <Point> currentwave = new List <Point> {
                    from
                };

                while (!CheckTo(currentwave, to))
                {
                    List <Point> nextvawe = new List <Point>();
                    foreach (Point nextpoint in currentwave)
                    {
                        foreach (Point offset in horseSteps)
                        {
                            Point p = ShiftPoint(nextpoint, offset);

                            p.from = nextpoint.ToString();

                            /*
                             * здесь можно вставить проверку не занято ли поле с координатами р
                             *
                             */
                            nextvawe.Add(p);
                        }

                        currentwave = nextvawe;
                    }
                }
                path = "\"" + foundedFrom + "\"," + path;

                to = ParsePoint(foundedFrom);
            }

            return("[" + path);
        }