/// <summary> /// Increment the generation and move all locs. /// </summary> /// <returns>True if at least one loc has moved, false otherwise.</returns> public bool Increment(FutureAlternativeSet genSet, IEnumerable <ILocState> locs, ILocState testLoc, out bool stationReached) { generation++; stationReached = false; // Try to move the test loc first var moved = MoveLoc(genSet, testLoc); // Are we in a block that is considered a station for the loc? var block = state.GetCurrentBlock(testLoc); if ((block != null) && (block.IsStationFor(testLoc))) { // Yes, the loc may stop here stationReached = true; return(true); } if (moved) { // We've moved so still no deadlock return(true); } // Try one of the other locs foreach (var loc in locs.Where(x => x != testLoc)) { moved = MoveLoc(genSet, loc); if (moved) { // Something moved return(true); } } return(false); }