Exemplo n.º 1
0
        private List <string> FindRoute(string start, string destination)
        {
            List <string> Points = new List <string>();

            graph.shortest_path(start, destination).ForEach(x => Points.Add(x));

            Points.Reverse();

            return(Points);
        }
Exemplo n.º 2
0
        private List <string> FindRoute(string start, string destination)
        {
            List <string> Points = new List <string>();

            graph.shortest_path(start, destination).ForEach(x => Points.Add(x));

            Points.Reverse();

            for (var i = 0; i < Points.Count; i++)
            {
                Console.WriteLine(Points[i]);
            }

            return(Points);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Start task method
        /// </summary>
        /// <param name="r"></param>
        public void StartTask(Robot r)
        {
            suitcase.x = r.x;
            suitcase.y = r.y + 0.3;
            suitcase.z = r.z;

            r.SetSuitcase(suitcase);

            if (!walkingHome && bringHome)
            {
                r.AddTask(new RobotMove(g.shortest_path(pickupNode, 'A'), coordinates, g));
                r.AddTask(new RobotRelease(suitcase, home, true, true));
                walkingHome = true;
            }
        }
Exemplo n.º 4
0
        private List <string> FindRoute(string start, string destination)
        {
            Graph         g      = new Graph();
            List <string> Points = new List <string>();

            g.add_vertex("null3", new Dictionary <string, int>()
            {
                { "null2", 4 }
            });
            g.add_vertex("null2", new Dictionary <string, int>()
            {
                { "null1", 4 }, { "null3", 4 }
            });
            g.add_vertex("null1", new Dictionary <string, int>()
            {
                { "A", 4 }, { "null2", 4 }
            });
            g.add_vertex("A", new Dictionary <string, int>()
            {
                { "B", 15 }, { "A1", 3 }, { "A2", 6 }, { "A3", 9 }, { "A4", 12 }, { "null1", 4 }
            });
            g.add_vertex("A1", new Dictionary <string, int>()
            {
                { "B", 12 }
            });
            g.add_vertex("A2", new Dictionary <string, int>()
            {
                { "B", 9 }
            });
            g.add_vertex("A3", new Dictionary <string, int>()
            {
                { "B", 6 }
            });
            g.add_vertex("A4", new Dictionary <string, int>()
            {
                { "B", 3 }
            });
            g.add_vertex("B", new Dictionary <string, int>()
            {
                { "C", 9 }, { "J", 9 }, { "B1", 3 }, { "B2", 6 }, { "B3", 9 }, { "B4", 12 }
            });
            g.add_vertex("B1", new Dictionary <string, int>()
            {
                { "J", 12 }
            });
            g.add_vertex("B2", new Dictionary <string, int>()
            {
                { "J", 9 }
            });
            g.add_vertex("B3", new Dictionary <string, int>()
            {
                { "J", 6 }
            });
            g.add_vertex("B4", new Dictionary <string, int>()
            {
                { "J", 3 }
            });
            g.add_vertex("C", new Dictionary <string, int>()
            {
                { "D", 9 }, { "F", 15 }, { "C1", 3 }, { "C2", 6 }, { "C3", 9 }, { "C4", 12 }
            });
            g.add_vertex("C1", new Dictionary <string, int>()
            {
                { "F", 12 }
            });
            g.add_vertex("C2", new Dictionary <string, int>()
            {
                { "F", 9 }
            });
            g.add_vertex("C3", new Dictionary <string, int>()
            {
                { "F", 6 }
            });
            g.add_vertex("C4", new Dictionary <string, int>()
            {
                { "F", 3 }
            });
            g.add_vertex("D", new Dictionary <string, int>()
            {
                { "E", 15 }, { "N", 9 }, { "D1", 3 }, { "D2", 6 }, { "D3", 9 }, { "D4", 12 }
            });
            g.add_vertex("D1", new Dictionary <string, int>()
            {
                { "E", 12 }
            });
            g.add_vertex("D2", new Dictionary <string, int>()
            {
                { "E", 9 }
            });
            g.add_vertex("D3", new Dictionary <string, int>()
            {
                { "E", 6 }
            });
            g.add_vertex("D4", new Dictionary <string, int>()
            {
                { "E", 3 }
            });
            g.add_vertex("E", new Dictionary <string, int>()
            {
                { "F", 9 }, { "G", 15 }, { "E1", 3 }, { "E2", 6 }, { "E3", 9 }, { "E4", 12 }
            });
            g.add_vertex("E1", new Dictionary <string, int>()
            {
                { "G", 12 }
            });
            g.add_vertex("E2", new Dictionary <string, int>()
            {
                { "G", 9 }
            });
            g.add_vertex("E3", new Dictionary <string, int>()
            {
                { "G", 6 }
            });
            g.add_vertex("E4", new Dictionary <string, int>()
            {
                { "G", 3 }
            });
            g.add_vertex("F", new Dictionary <string, int>()
            {
                { "A", 9 }, { "H", 15 }, { "F1", 3 }, { "F2", 6 }, { "F3", 9 }, { "F4", 12 }
            });
            g.add_vertex("F1", new Dictionary <string, int>()
            {
                { "H", 12 }
            });
            g.add_vertex("F2", new Dictionary <string, int>()
            {
                { "H", 9 }
            });
            g.add_vertex("F3", new Dictionary <string, int>()
            {
                { "H", 6 }
            });
            g.add_vertex("F4", new Dictionary <string, int>()
            {
                { "H", 3 }
            });
            g.add_vertex("G", new Dictionary <string, int>()
            {
                { "H", 9 }, { "R", 15 }, { "G1", 3 }, { "G2", 6 }, { "G3", 9 }, { "G4", 12 }
            });
            g.add_vertex("G1", new Dictionary <string, int>()
            {
                { "R", 12 }
            });
            g.add_vertex("G2", new Dictionary <string, int>()
            {
                { "R", 9 }
            });
            g.add_vertex("G3", new Dictionary <string, int>()
            {
                { "R", 6 }
            });
            g.add_vertex("G4", new Dictionary <string, int>()
            {
                { "R", 3 }
            });
            g.add_vertex("H", new Dictionary <string, int>()
            {
                { "I", 9 }, { "S", 15 }, { "H1", 3 }, { "H2", 6 }, { "H3", 9 }, { "H4", 12 }
            });
            g.add_vertex("H1", new Dictionary <string, int>()
            {
                { "S", 12 }
            });
            g.add_vertex("H2", new Dictionary <string, int>()
            {
                { "S", 9 }
            });
            g.add_vertex("H3", new Dictionary <string, int>()
            {
                { "S", 6 }
            });
            g.add_vertex("H4", new Dictionary <string, int>()
            {
                { "S", 3 }
            });
            g.add_vertex("I", new Dictionary <string, int>()
            {
                { "A", 15 }, { "I1", 3 }, { "I2", 6 }, { "I3", 9 }, { "I4", 12 }
            });
            g.add_vertex("I1", new Dictionary <string, int>()
            {
                { "A", 12 }
            });
            g.add_vertex("I2", new Dictionary <string, int>()
            {
                { "A", 9 }
            });
            g.add_vertex("I3", new Dictionary <string, int>()
            {
                { "A", 6 }
            });
            g.add_vertex("I4", new Dictionary <string, int>()
            {
                { "A", 3 }
            });
            g.add_vertex("J", new Dictionary <string, int>()
            {
                { "K", 9 }
            });
            g.add_vertex("K", new Dictionary <string, int>()
            {
                { "L", 9 }, { "C", 15 }, { "K1", 3 }, { "K2", 6 }, { "K3", 9 }, { "K4", 12 }
            });
            g.add_vertex("K1", new Dictionary <string, int>()
            {
                { "C", 12 }
            });
            g.add_vertex("K2", new Dictionary <string, int>()
            {
                { "C", 9 }
            });
            g.add_vertex("K3", new Dictionary <string, int>()
            {
                { "C", 6 }
            });
            g.add_vertex("K4", new Dictionary <string, int>()
            {
                { "C", 3 }
            });
            g.add_vertex("L", new Dictionary <string, int>()
            {
                { "M", 9 }, { "D", 15 }, { "L1", 3 }, { "L2", 6 }, { "L3", 9 }, { "L4", 12 }
            });
            g.add_vertex("L1", new Dictionary <string, int>()
            {
                { "D", 12 }
            });
            g.add_vertex("L2", new Dictionary <string, int>()
            {
                { "D", 9 }
            });
            g.add_vertex("L3", new Dictionary <string, int>()
            {
                { "D", 6 }
            });
            g.add_vertex("L4", new Dictionary <string, int>()
            {
                { "D", 3 }
            });
            g.add_vertex("M", new Dictionary <string, int>()
            {
                { "N", 15 }, { "M1", 3 }, { "M2", 6 }, { "M3", 9 }, { "M4", 12 }
            });
            g.add_vertex("M1", new Dictionary <string, int>()
            {
                { "N", 12 }
            });
            g.add_vertex("M2", new Dictionary <string, int>()
            {
                { "N", 9 }
            });
            g.add_vertex("M3", new Dictionary <string, int>()
            {
                { "N", 6 }
            });
            g.add_vertex("M4", new Dictionary <string, int>()
            {
                { "N", 3 }
            });
            g.add_vertex("N", new Dictionary <string, int>()
            {
                { "O", 15 }, { "N1", 3 }, { "N2", 6 }, { "N3", 9 }, { "N4", 12 }
            });
            g.add_vertex("N1", new Dictionary <string, int>()
            {
                { "O", 12 }
            });
            g.add_vertex("N2", new Dictionary <string, int>()
            {
                { "O", 9 }
            });
            g.add_vertex("N3", new Dictionary <string, int>()
            {
                { "O", 6 }
            });
            g.add_vertex("N4", new Dictionary <string, int>()
            {
                { "O", 3 }
            });
            g.add_vertex("O", new Dictionary <string, int>()
            {
                { "P", 15 }, { "E", 15 }, { "O1", 3 }, { "O2", 6 }, { "O3", 9 }, { "O4", 12 }
            });
            g.add_vertex("O1", new Dictionary <string, int>()
            {
                { "P", 12 }
            });
            g.add_vertex("O2", new Dictionary <string, int>()
            {
                { "P", 9 }
            });
            g.add_vertex("O3", new Dictionary <string, int>()
            {
                { "P", 6 }
            });
            g.add_vertex("O4", new Dictionary <string, int>()
            {
                { "P", 3 }
            });
            g.add_vertex("P", new Dictionary <string, int>()
            {
                { "Q", 15 }, { "G", 15 }, { "P1", 3 }, { "P2", 6 }, { "P3", 9 }, { "P4", 12 }
            });
            g.add_vertex("P1", new Dictionary <string, int>()
            {
                { "Q", 12 }
            });
            g.add_vertex("P2", new Dictionary <string, int>()
            {
                { "Q", 9 }
            });
            g.add_vertex("P3", new Dictionary <string, int>()
            {
                { "Q", 6 }
            });
            g.add_vertex("P4", new Dictionary <string, int>()
            {
                { "Q", 3 }
            });
            g.add_vertex("Q", new Dictionary <string, int>()
            {
                { "R", 9 }
            });
            g.add_vertex("R", new Dictionary <string, int>()
            {
                { "S", 9 }
            });
            g.add_vertex("S", new Dictionary <string, int>()
            {
                { "T", 9 }
            });
            g.add_vertex("T", new Dictionary <string, int>()
            {
                { "I", 15 }, { "T1", 3 }, { "T2", 6 }, { "T3", 9 }, { "T4", 12 }
            });
            g.add_vertex("T1", new Dictionary <string, int>()
            {
                { "I", 12 }
            });
            g.add_vertex("T2", new Dictionary <string, int>()
            {
                { "I", 9 }
            });
            g.add_vertex("T3", new Dictionary <string, int>()
            {
                { "I", 6 }
            });
            g.add_vertex("T4", new Dictionary <string, int>()
            {
                { "I", 3 }
            });
            g.shortest_path(start, destination).ForEach(x => Points.Add(x));

            Points.Reverse();

            for (var i = 0; i < Points.Count; i++)
            {
                Console.WriteLine(Points[i]);
            }

            return(Points);
        }