class Destinations: """ Generates a sequence of destinations (None, 'W', 'S') """ def __init__(self): """Add internal data.""" self._arrivals = ( # 0:52, 1:26, 2:22 2, 2, 2, 2, 2, 1, 2, 2, 2, 1, 1, 2, 1, 2, 2, 2, 1, 2, 1, 1, 2, 1, 1, 0, 2, 0, 0, 0, 0, 1, 2, 0, 0, 0, 1, 0, 0, 2, 0, 1, 2, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2, 0, 0, 1, 2, 0, 1, 0, 2, 0, 2, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1) self._internal_time = 0 self._total_cycle = len(self._arrivals) def step(self): """Make one time step, reporting the desination of the next vehicle (or None).""" ind = self._arrivals[self._internal_time] self._internal_time = (self._internal_time + 1) % len(self._arrivals) return 'W' if ind == 1 else 'S' if ind == 2 else None