Esempio n. 1
0
        public void RewindUntilOrigin(List <Node> stations)
        {
            Path.Add(stations[DestinationID]);
            int         index;
            bool        ongoing    = true;
            List <Node> neighbours = new List <Node>();

            do
            {
                neighbours = MetroNetwork.GenChildren(Path[0]); // may run into problems with aliasing
                foreach (Node n in neighbours)                  // may run into problems with foreach
                {
                    index = n.StationID;

                    if (Path[0].ValidRewind(stations[index], OriginID))
                    {
                        AddOn(stations[index]);
                        if (index == OriginID)
                        {
                            ongoing = false;
                        }
                    }
                }
                neighbours.Clear();
            } while (ongoing);
        }
Esempio n. 2
0
        private void NextGeneration(int parentID, bool firstPass = false)
        {
            Node parent = new Node();

            parent = Stations[parentID]; // aliasing problems maybe

            List <Node> children = new List <Node>();

            children = MetroNetwork.GenChildren(parent);
            int index;

            foreach (var child in children)
            {
                index = child.StationID;
                Stations[index].ClonePositionAndID(child);

                if (Stations[index].UpdateScore(parent, firstPass))
                {
                    AddOnToList(index);
                }
            }

            RemoveFromList(parentID);
        }