Exemplo n.º 1
0
 public Robot(int x, int y, int r, char d)
 {
     this.X = x;
     this.Y = y;
     this.Range = r;
     this.Dir = d;
     //empty memory for robot
     this.Memory = new Map();
     this.XGoal = 13;
     this.YGoal = 18;
     this.XStart = 1;
     this.YStart = 1;
     this.StartNode = new Node(this.XStart, this.YStart);
     this.GoalNode = new Node(this.XGoal, this.YGoal);
     this.ShortestPath = new List<Node>();
     this.VirtualMap = new Map();
 }
Exemplo n.º 2
0
 public Simulator(Robot r, Map m)
 {
     this.Robot = r;
     this.Map = m;
     this.Robot.Env = this.Map;
 }
Exemplo n.º 3
0
 public Simulator()
 {
     this.Robot = new Robot(1, 1, 1,'U');
     this.Map = new Map();
 }
Exemplo n.º 4
0
        private void updateRealTimeMap(string s)
        {
            int x, y;
            bool result = Int32.TryParse(s.Substring(1,2), out x);
            if (!result)
                Console.WriteLine("String could not be parsed.");
            result = Int32.TryParse(s.Substring(3, 2), out y);
            if (!result)    
                Console.WriteLine("String could not be parsed.");
            Console.WriteLine("X = {0}, Y = {1}", x, y);
            Console.WriteLine("String size: " + s.Length);
            int[,] data = new int[20, 15];
            int pointer = 5;
            try
            {
                for (int i = 0; i < 20; i++)
                {
                    for (int j = 0; j < 15; j++)
                    {
                        data[i, j] = (int)Char.GetNumericValue(s[pointer++]);
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("The map size may not be 300 chars");
            }

            Map memory = new Map(data);
            memory.print();
            this.realTimeRobot.Memory = memory;
            this.realTimeRobot.X = x;
            this.realTimeRobot.Y = y;
            if (!this.fastestRuning) 
            {
                bool saved = this.realTimeRobot.Memory.saveToHardDriveRealTime("E:/Git/MDP-Jan-2015/PCSimulator/MDPSimulator/");
                if (saved)
                {
                    displayConsoleMessage("Map descriptor exported successfully!");
                }
                else
                    displayConsoleMessage("Failed to export map descriptor!");
            }
            if (s[s.Length - 1] == 'F')
            {
                this.fastestRuning = true;
            }

        }
Exemplo n.º 5
0
 private void dfsExplore_Click(object sender, RoutedEventArgs e)
 {
     this.displayConsoleMessage("Exploring using DFS...");
     Robot robot = new Robot();
     this.map = new Map(mapDescriptor);
     this.simulator = new Simulator(robot, map);
     this.simulator.Robot.ChangePosition += new Robot.RobotMovingHandler(updateRobotPosition);
     this.simulator.Robot.SendingMessage += new Robot.RobotSendingMessage(displayRobotMessage);
     this.timeLimit = UserSetting.TimeLimit;
     this.coverageLimit = UserSetting.CoverageLimit;
     timer.Start();
     if (exploreThread!=null)
         exploreThread.Abort();
     exploreThread = new Thread(this.simulator.dfsExplore);
     exploreThread.Start();
 }
Exemplo n.º 6
0
 private void setUpSimulator()
 {
     Robot robot = new Robot();
     robot.X = init_Y;
     robot.Y = init_X;
     robot.Dir = 'D';
     this.map = new Map(mapDescriptor);
     this.simulator = new Simulator(robot, map);
     this.simulator.Robot.ChangePosition += new Robot.RobotMovingHandler(updateRobotPosition);
     this.simulator.Robot.SendingMessage += new Robot.RobotSendingMessage(displayRobotMessage);
     this.timeLimit = UserSetting.TimeLimit;
     this.TimerProgressbar.Value = 100;
     this.coverageLimit = UserSetting.CoverageLimit;
 }
Exemplo n.º 7
0
 private void exploreButton_Click(object sender, RoutedEventArgs e)
 {
     if (radioButtons[1])
     {
         dfsExplore();
         return;
     }
     else if (!radioButtons[0])
     {
         this.displayConsoleMessage("Please Select Exploration Algorithm!");
         return;
     }
     this.displayConsoleMessage("Exploring using wall follower!!!");
     Robot robot = new Robot();
     this.map = new Map(mapDescriptor);
     this.simulator = new Simulator(robot, map);
     this.simulator.Robot.ChangePosition += new Robot.RobotMovingHandler(updateRobotPosition);
     this.simulator.Robot.SendingMessage += new Robot.RobotSendingMessage(displayRobotMessage);
     this.timeLimit = UserSetting.TimeLimit;
     this.coverageLimit = UserSetting.CoverageLimit;
     timer.Start();
     exploreThread = new Thread(this.simulator.wallfollowerExplore);
     exploreThread.Start();
 }
Exemplo n.º 8
0
        public string realTimeShortestPath(string s)
        {
            int[,] data = new int[20, 15];
            int pointer = 5;
            string path;
            try
            {
                for (int i = 0; i < 20; i++)
                {
                    for (int j = 0; j < 15; j++)
                    {
                        data[i, j] = (int)Char.GetNumericValue(s[pointer++]);
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("The map size may not be 300 chars");
            }

            this.Memory = new Map(data);
            Console.WriteLine("Data");
            this.Memory.print();
            fastestRun();
            if (this.shortestPathComputed)
            {
                path = constructPathForRealTime();
                OnSendingMessage("The mapping has no solution for shortest path");
                return path;
            }
            else
            {
                return null;
            }
        }
Exemplo n.º 9
0
 public Robot()
 {
     this.X = 1;
     this.Y = 1;
     this.Range = 1;
     this.Dir = 'U';
     this.Memory = new Map();
     this.XGoal = 13;
     this.YGoal = 18;
     this.XStart = 1;
     this.YStart = 1;
     this.StartNode = new Node(this.XStart, this.YStart);
     this.GoalNode = new Node(this.XGoal, this.YGoal);
     this.StartDFSNode = new DFSNode(this.XStart, this.YStart);
     this.GoalDFSNode = new DFSNode(this.XGoal, this.YGoal);
     this.ShortestPath = new List<Node>();
     this.VirtualMap = new Map();
     this.DFSNodes = new List<DFSNode>();
     this.priorityNodes = new List<Node>();
     this.CurrentCoverage = 0;
 }