コード例 #1
0
ファイル: Cell.cs プロジェクト: fraqtop/new_maze
 public string GetDirection(Cell bestNeightbour)
 {
     if (bestNeightbour == this.upper) return "D";
     if (bestNeightbour == this.right) return "L";
     if (bestNeightbour == this.lower) return "U";
     return "R";
 }
コード例 #2
0
ファイル: Maze.cs プロジェクト: fraqtop/new_maze
 public Maze(string mazepath)
 {
     this.way = string.Empty;
     this.points = new List<Cell>();
     this.StringPointers = new List<Cell>();
     var filedata = File.ReadLines(mazepath).ToList();
     Cell currentCell;
     foreach (string s in filedata)
     {
         currentCell = new Cell(s[0]);
         StringPointers.Add(currentCell);
         for (int i = 1; i < s.Length; i++)
         {
             currentCell.right = new Cell(s[i]);
             if (s[i] == 'e')
                 this.exitCell = currentCell.right;
             if (s[i] == '*')
                 this.entryCell = currentCell.right;
             if ("123456789".Contains(s[i]))
                 points.Add(currentCell.right);
             currentCell.right.left = currentCell;
             currentCell = currentCell.right;
         }
     }
     Cell nextLineCurrentCell;
     for (int i = 0; i < StringPointers.Count-1; i++)
     {
         currentCell = StringPointers[i];
         nextLineCurrentCell = StringPointers[i + 1];
         while (currentCell != null | nextLineCurrentCell != null)
         {
             currentCell.lower = nextLineCurrentCell;
             nextLineCurrentCell.upper = currentCell;
             currentCell = currentCell.right;
             nextLineCurrentCell = nextLineCurrentCell.right;
         }
     }
 }
コード例 #3
0
ファイル: Maze.cs プロジェクト: fraqtop/new_maze
 private void Locate(Cell cellPointer)
 {
     cellPointer.SetDistance(0);
 }