Exemple #1
0
        public HexaPath ConvertToPath(AgentMotionSequence sequence, HexaPos currentPos)
        {
            HexagonalMap map  = GetMap();
            HexaPath     path = new HexaPath();

            path.AddPos(currentPos);

            List <HexagonalMap.Direction> .Enumerator e = sequence.mMotions.GetEnumerator();

            while (e.MoveNext())
            {
                HexagonalMap.Direction step = e.Current;
                currentPos = map.GetNext(currentPos, step);
                path.AddPos(currentPos);
            }

            return(path);
        }
Exemple #2
0
 public void Move(HexagonalMap.Direction step)
 {
     motion.AddOneStep(step);
     _currentPos = _map.GetNext(_currentPos, step);
     path.AddPos(_currentPos);
 }
Exemple #3
0
 public void AddOneStep(HexagonalMap.Direction step)
 {
     mMotions.Add(step);
 }
Exemple #4
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();
            }
        }