Example #1
0
        private void btnRobotPath_Click(object sender, EventArgs e)
        {
            if (this.rbBatchTest.Checked == true)
            {
                //ParameterTester tester = new ParameterTester(this);
                //GdParameterTester tester = new GdParameterTester(this);
                TeleportTester tester = new TeleportTester(this);
                tester.Run();
                MessageBox.Show("Finished batch test");
            }
            else
            {
                // apply parameters
                _human.WingmanToleranceRange = int.Parse(tbWR.Text);
                _human.SetObservationRange(int.Parse(tbHR.Text));

                TopologyGraphGenerator topologyGenerator = new TopologyGraphGenerator(_map);

                TopologyGraph tograph = topologyGenerator.GetTopologyGraph();
                //graph.Print();
                tograph.Draw();

                PlanningGraphGenerator planningGenerator = new PlanningGraphGenerator(tograph);
                PathPlanningGraph      planGraph         = planningGenerator.GetPathPlanningGraph(this.HumanPath, this.human.WingmanToleranceRange);

                planGraph.Draw();

                HexaPos startPos = _human.path[0];

                PlanningGraphPruner pruner       = new PlanningGraphPruner();
                PathPlanningGraph   newPlanGraph = pruner.GetPlanningGraph(planGraph, startPos);

                newPlanGraph.Draw("PlanningGraph2");

                PathPlanningGraph prunedPlanGraph = pruner.BackwardPrune(newPlanGraph);
                prunedPlanGraph = pruner.ForwardPrune(prunedPlanGraph);

                prunedPlanGraph.Draw("PrunedPlanningGraph");

                /*
                 * ExhaustiveDFSPathPlanner planner = new ExhaustiveDFSPathPlanner(_map, _robot);
                 * HexaPath maxPath = planner.FindPath(prunedPlanGraph, startPos);
                 *
                 * Console.WriteLine("PATH BY EXHAUSTIVE DFS: " + maxPath.ToString());
                 */

                _planningForm = new PlanningForm(prunedPlanGraph, _map, _robot, startPos, _mapDrawer, _human.path);
                _planningForm.Show();
            }
        }
Example #2
0
        private void tbPlan_Click(object sender, EventArgs e)
        {
            int planLength = 0;

            if (this.tbPlanLength.Text != "")
            {
                planLength = Int32.Parse(this.tbPlanLength.Text);
            }
            else
            {
                planLength = 0;
            }

            Random  rnd     = new Random();
            int     start_x = this.mapViewForm.map.mapState.ActiveHex.posX;
            int     start_y = this.mapViewForm.map.mapState.ActiveHex.posY;
            HexaPos pos     = new HexaPos(start_x, start_y);

            if (this.rbRandom.Checked == true)
            {
                HexaPath path = new HexaPath();
                path.AddPos(pos);
                for (int t = 0; t < planLength; t++)
                {
                    int rndIdx = rnd.Next(5);
                    HexagonalMap.Direction direction = mapViewForm.map.directionList[rndIdx];
                    HexaPos newPos = mapViewForm.map.GetNext(path[t], direction);
                    path.AddPos(newPos);
                }

                LoadActivePath(path);

                mapViewForm.Refresh();
            }
            else if (this.rbInfoMax.Checked == true)
            {
                InfoMaxPathPlanner planner
                    = new InfoMaxPathPlanner(mapViewForm.map, (Robot)mapViewForm.robot);

                HexaPos startPos = new HexaPos(mapViewForm.startHex.posX, mapViewForm.startHex.posY);

                TopologyGraphGenerator topologyGenerator = new TopologyGraphGenerator(mapViewForm.map);
                TopologyGraph          tograph           = topologyGenerator.GetTopologyGraph();
                tograph.Draw();
                PlanningGraphGenerator planningGenerator = new PlanningGraphGenerator(tograph);
                PathPlanningGraph      graph             = planningGenerator.GetPathPlanningGraph(startPos, Int32.Parse(this.tbPlanLength.Text));
                graph.Draw();
                planner.iteratingOnce = true;
                HexaPath maxPath = planner.FindPath(graph, startPos);

                LoadActivePath(maxPath);

                mapViewForm.Refresh();
            }
            else if (this.rbDistMin.Checked == true)
            {
                DistMinPathPlanner planner  = new DistMinPathPlanner(mapViewForm.map, (Robot)mapViewForm.robot);
                HexaPos            startPos = new HexaPos(mapViewForm.startHex.posX, mapViewForm.startHex.posY);
                HexaPos            endPos   = new HexaPos(mapViewForm.endHex.posX, mapViewForm.endHex.posY);

                TopologyGraphGenerator topologyGenerator = new TopologyGraphGenerator(mapViewForm.map);
                TopologyGraph          tograph           = topologyGenerator.GetTopologyGraph();

                HexaPath path = planner.FindPath(tograph, startPos, endPos);

                LoadActivePath(path);
                mapViewForm.Refresh();
            }
        }