def is_admissible( self, vehicle_id: str, index: VehicleIndex, vehicle_ids_in_bubbles: Dict["Bubble", Set[str]], running_cursors: Set["Cursor"], ): """The vehicle_id we are querying for and the `other_vehicle_ids` _presently in this `sstudio.types.Bubble`_. """ for prefix in self.exclusion_prefixes: if vehicle_id.startswith(prefix): return False if self._limit is not None: # Already hijacked (according to VehicleIndex) + to be hijacked (running cursors) current_hijacked_or_shadowed_vehicle_ids = { v_id for v_id in vehicle_ids_in_bubbles[self] if index.vehicle_is_hijacked(v_id) or index.vehicle_is_shadowed(v_id) } per_bubble_veh_ids = BubbleManager.vehicle_ids_per_bubble( frozenset(running_cursors)) running_hijacked_or_shadowed_vehicle_ids = per_bubble_veh_ids[self] all_hijacked_or_shadowed_vehicle_ids = ( current_hijacked_or_shadowed_vehicle_ids | running_hijacked_or_shadowed_vehicle_ids) - {vehicle_id} if len(all_hijacked_or_shadowed_vehicle_ids) >= self._limit: return False return True
def is_admissible( self, vehicle_id: str, index: VehicleIndex, prev_cursors, running_cursors ): """The vehicle_id we are querying for and the `other_vehicle_ids` _presently in this `sstudio.types.Bubble`_. """ for prefix in self.exclusion_prefixes: if vehicle_id.startswith(prefix): return False if self._limit is not None: # Already hijacked (according to VehicleIndex) + to be hijacked (running cursors) current_hijacked_or_shadowed_vehicle_ids = { v_id for v_id in BubbleManager.vehicle_ids_in_bubble(self, prev_cursors) if index.vehicle_is_hijacked(v_id) or index.vehicle_is_shadowed(v_id) } running_hijacked_or_shadowed_vehicle_ids = BubbleManager.vehicle_ids_in_bubble( self, running_cursors ) all_hijacked_or_shadowed_vehicle_ids = ( current_hijacked_or_shadowed_vehicle_ids | running_hijacked_or_shadowed_vehicle_ids ) if len(all_hijacked_or_shadowed_vehicle_ids) >= self._limit: return False return True
def admissibility( self, vehicle_id: str, index: VehicleIndex, vehicle_ids_in_bubbles: Dict["Bubble", Set[str]], running_cursors: Set["Cursor"], ): """The vehicle_id we are querying for and the `other_vehicle_ids` _presently in this `sstudio.types.Bubble`_. """ for prefix in self.exclusion_prefixes: if vehicle_id.startswith(prefix): return False, False hijackable, shadowable = True, True if self._limit is not None: # Already hijacked (according to VehicleIndex) + to be hijacked (running cursors) current_hijacked_vehicle_ids = { v_id for v_id in vehicle_ids_in_bubbles[self] if index.vehicle_is_hijacked(v_id) } current_shadowed_vehicle_ids = { v_id for v_id in vehicle_ids_in_bubbles[self] if index.vehicle_is_shadowed(v_id) } vehicle_ids_by_bubble_state = ( BubbleManager._vehicle_ids_divided_by_bubble_state( frozenset(running_cursors) ) ) # pytype: disable=unsupported-operands all_hijacked_vehicle_ids = ( current_hijacked_vehicle_ids | vehicle_ids_by_bubble_state[BubbleState.InAirlock][self] ) - {vehicle_id} all_shadowed_vehicle_ids = ( current_shadowed_vehicle_ids | vehicle_ids_by_bubble_state[BubbleState.InBubble][self] ) - {vehicle_id} # pytype: enable=unsupported-operands hijackable = len(all_hijacked_vehicle_ids) < ( self._limit.hijack_limit or maxsize ) shadowable = len(all_shadowed_vehicle_ids) + len( all_hijacked_vehicle_ids ) < (self._limit.shadow_limit or maxsize) return hijackable, shadowable