/// <summary>
            /// Try to move the given loc to a new block.
            /// </summary>
            /// <returns>True if the loc has moved, false if there are no routes available.</returns>
            private bool MoveLoc(FutureAlternativeSet genSet, ILocState loc)
            {
                // Get possible routes
                var currentBlock          = state.GetCurrentBlock(loc);
                var currentBlockEnterSide = state.GetCurrentBlockEnterSide(loc);
                var locDirection          = currentBlockEnterSide.Invert();
                var avoidDirectionChanges = (loc.ChangeDirection == ChangeDirection.Avoid);
                var routeFromFromBlock    = state.RailwayState.GetAllPossibleNonClosedRoutesFromBlock(currentBlock);
                var routeOptions          = routeFromFromBlock.Select(x => state.IsAvailableFor(x, loc, locDirection, avoidDirectionChanges, 0)).ToList();
                var possibleRoutes        = routeOptions.Where(x => x.IsPossible).Select(x => x.Route).ToList();

                // If no routes, then return
                if (!possibleRoutes.Any())
                {
                    return(false);
                }
                if (possibleRoutes.Count > 1)
                {
                    // Create alternate generations
                    foreach (var route in possibleRoutes.Skip(1))
                    {
                        var alternateState = new FutureRouteAvailabilityTester(state);
                        alternateState.TakeRoute(route, loc);
                        genSet.Add(new FutureAlternative(alternateState, generation));
                    }
                }
                // Take the first route
                var firstRoute = possibleRoutes[0];

                state.TakeRoute(firstRoute, loc);
                return(true);
            }
 /// <summary>
 /// Initialize from given state
 /// </summary>
 internal FutureRouteAvailabilityTester(FutureRouteAvailabilityTester source)
     : base(source.railwayState)
 {
     foreach (var loc in railwayState.LocStates)
     {
         locStates[loc] = new LocState(source.locStates[loc]);
     }
 }
 /// <summary>
 /// Default ctor
 /// </summary>
 public FutureAlternative(FutureRouteAvailabilityTester state, int generation)
 {
     if (state == null)
     {
         throw new ArgumentNullException("state");
     }
     this.state      = state;
     this.generation = generation;
 }
            /// <summary>
            /// Default ctor
            /// </summary>
            public FutureAlternativeSet(LiveRouteAvailabilityTester live, IRouteState route, ILocState loc)
            {
                this.testLoc   = loc;
                minGenerations = live.railwayState.BlockStates.Count;
                var tester = new FutureRouteAvailabilityTester(live.railwayState);

                tester.TakeRoute(route, loc);
                alternatives.Add(new FutureAlternative(tester, 0));
                autoLocs = live.railwayState.LocStates.Where(x => x.ControlledAutomatically.Actual && (x.CurrentBlock.Actual != null)).ToList();
            }