示例#1
0
文件: Bot.cs 项目: maxymnaumchyk/BSD
        public bool MakeStep3()
        {
            //достигли выхода?
            if (Maze[Robot3.Location] == Cell.Exit)
            {
                return(false);
            }

            //получаем значение ячейки слева
            var righr3 = Maze[Robot3.Location + Robot3.Direction.Rotate(-1)];

            //если слева нет стены - поворачиваем налево
            if (righr3 != Cell.Wall)
            {
                Robot3.Direction = Robot3.Direction.Rotate(-1);
            }
            else
            {
                //пока впереди есть стена - поворачиваем направо
                while (Maze[Robot3.Location + Robot3.Direction] == Cell.Wall)
                {
                    Robot3.Direction = Robot3.Direction.Rotate(1);
                }
            }
            //идем вперед
            Robot3.GoForward();
            return(true);
        }
示例#2
0
 public static void DrawMaze(Maze maze, Robot robot, Robot2 robot2, Robot3 robot3)
 {
     Console.Clear();
     for (int row = 0; row < maze.Height; row++)
     {
         for (int col = 0; col < maze.Width; col++)
             switch (maze[col, row])
             {
                 case Cell.Wall: Console.Write('#'); break;
                 case Cell.Exit: Console.Write('E'); break;
                 default: Console.Write(' '); break;
             }
         Console.WriteLine();
     }
     
     Console.SetCursorPosition(robot.Location.X, robot.Location.Y);
     Console.Write("1");
     Console.SetCursorPosition(robot2.Location.X, robot2.Location.Y);
     Console.Write("2");
     Console.SetCursorPosition(robot3.Location.X, robot3.Location.Y);
     Console.Write("3");
 }