Beispiel #1
0
        public void Solve(BoxPath boxPath, Box begin, Box end)
        {
            RecursiveSolveCallCounter.IncreaseOne();
            BoxPath newBoxPath;

            if (begin == null)
            {
            }
            else if (begin.Row == end.Row && begin.Column == end.Column)
            {
                newBoxPath = boxPath.Clone();
                newBoxPath.Add(begin);
                if (newBoxPath.Sum() <= this.totalRankingList.LowestSum)
                {
                    this.totalRankingList.Add(newBoxPath);
                    //Console.WriteLine($"Count:{this.totalRankingList.Count}, Low:{this.totalRankingList.LowestSum}, BoxPath:{newBoxPath}, Begin:{begin}, End:{end}");
                }
            }
            else if (!boxPath.IsFoundBox(begin))
            {
                newBoxPath = boxPath.Clone();
                newBoxPath.Add(begin);
                if (newBoxPath.Sum() <= this.totalRankingList.LowestSum)
                {
                    Solve(newBoxPath, euklidesSquareBox.Up(begin), end);
                    Solve(newBoxPath, euklidesSquareBox.Down(begin), end);
                    Solve(newBoxPath, euklidesSquareBox.Left(begin), end);
                    Solve(newBoxPath, euklidesSquareBox.Right(begin), end);
                }
            }
        }
Beispiel #2
0
 public void SolveRecursive(BoxPath boxPath, Box begin, Box end)
 {
     if (!boxPath.IsFoundBox(begin))
     {
         Solve(boxPath, euklidesSquareBox.Up(begin), end);
         Solve(boxPath, euklidesSquareBox.Down(begin), end);
         Solve(boxPath, euklidesSquareBox.Left(begin), end);
         Solve(boxPath, euklidesSquareBox.Right(begin), end);
     }
 }