def __init__(self, terminate_request_event, termination_complete_event, reload_request_event, bot_configuration, name, team, index, agent_class_wrapper, agent_metadata_queue, quick_chat_queue_holder): """ :param terminate_request_event: an Event (multiprocessing) which will be set from the outside when the program is trying to terminate :param termination_complete_event: an Event (multiprocessing) which should be set from inside this class when termination has completed successfully :param reload_request_event: an Event (multiprocessing) which will be set from the outside to force a reload of the agent :param reload_complete_event: an Event (multiprocessing) which should be set from inside this class when reloading has completed successfully :param bot_configuration: parameters which will be passed to the bot's constructor :param name: name which will be passed to the bot's constructor. Will probably be displayed in-game. :param team: 0 for blue team or 1 for orange team. Will be passed to the bot's constructor. :param index: The player index, i.e. "this is player number <index>". Will be passed to the bot's constructor. Can be used to pull the correct data corresponding to the bot's car out of the game tick packet. :param agent_class_wrapper: The ExternalClassWrapper object that can be used to load and reload the bot :param agent_metadata_queue: a Queue (multiprocessing) which expects to receive certain metadata about the agent once available. :param quick_chat_queue_holder: A data structure which helps the bot send and receive quickchat """ self.terminate_request_event = terminate_request_event self.termination_complete_event = termination_complete_event self.reload_request_event = reload_request_event self.bot_configuration = bot_configuration self.name = name self.team = team self.index = index self.agent_class_wrapper = agent_class_wrapper self.agent_metadata_queue = agent_metadata_queue self.logger = get_logger('bot' + str(self.index)) self.game_interface = GameInterface(self.logger) self.quick_chat_queue_holder = quick_chat_queue_holder self.last_chat_time = time.time() self.chat_counter = 0 self.reset_chat_time = True self.game_tick_packet = None self.bot_input = None
def __init__(self, name): super().__init__(name) self.logger = get_logger(name) self.__key = hash("BaseScript:" + name) self.game_tick_packet = GameTickPacket() self.ball_prediction = BallPrediction() self.game_interface = GameInterface(self.logger) self.game_interface.load_interface() fake_index = random.randint( 100, 10000) # a number unlikely to conflict with bots or other scripts self.renderer = self.game_interface.renderer.get_rendering_manager( bot_index=fake_index, bot_team=2) # Get matchcomms root if provided as a command line argument. try: pos = sys.argv.index("--matchcomms-url") potential_url = urlparse(sys.argv[pos + 1]) except (ValueError, IndexError): # Missing the command line argument. pass else: if potential_url.scheme == "ws" and potential_url.netloc: self.matchcomms_root = potential_url else: raise ValueError("The matchcomms url is invalid")
def __init__(self, agent_metadata_queue, quit_event, options): super().__init__(agent_metadata_queue, quit_event, options) # Sets up the logger. The string is the name of your hivemind. # This is configured inside your config file under hivemind_name. self.logger = get_logger(options['name']) # Give a warning if exec_path was given. if self.exec_path is not None: self.logger.warning( "An exec_path was given, but this is a PythonHivemind, and so it is ignored." ) self.logger.warning( " Try subclassing SubprocessHivemind if you want to use an executable." ) # The game interface is how you get access to things # like ball prediction, the game tick packet, or rendering. self.game_interface = GameInterface(self.logger) # drone_indices is a set of bot indices # which requested this hivemind with the same key. self.drone_indices = set() self._field_info = FieldInfoPacket()
def __init__(self): self.logger = get_logger('packet reader') self.game_interface = GameInterface(self.logger) self.game_interface.inject_dll() self.game_interface.load_interface() self.game_tick_packet = game_data_struct.GameTickPacket() self.rate_limit = rate_limiter.RateLimiter(GAME_TICK_PACKET_REFRESHES_PER_SECOND) self.last_call_real_time = datetime.now() # When we last called the Agent
def __init__(self): self.logger = get_logger(DEFAULT_LOGGER) self.game_interface = GameInterface(self.logger) self.quick_chat_manager = QuickChatManager(self.game_interface) self.quit_event = mp.Event() self.helper_process_manager = HelperProcessManager(self.quit_event) self.bot_quit_callbacks = [] self.agent_metadata_map = {}
def __init__(self, name, team, index): super().__init__(name, team, index) self.logger = get_logger('ExeSocket' + str(self.index)) self.is_retired = False self.executable_path = None self.game_interface = GameInterface(self.logger) self.game_tick_packet = GameTickPacket() self.spawn_id_seen = False
def __init__(self, agent_metadata_queue, quit_event, options): super().__init__(agent_metadata_queue, quit_event, options) self.logger = get_logger('scratch_mgr') self.game_interface = GameInterface(self.logger) self.current_sockets = set() self.running_indices = set() self.port: int = options['port'] self.sb3_file = options['sb3-file'] self.has_received_input = False
def __init__(self): self.logger = get_logger(DEFAULT_LOGGER) self.game_interface = GameInterface(self.logger) self.quit_event = mp.Event() self.helper_process_manager = HelperProcessManager(self.quit_event) self.bot_quit_callbacks = [] self.bot_reload_requests = [] self.agent_metadata_map = {} self.match_config: MatchConfig = None self.rlbot_gateway_process = None self.matchcomms_server: MatchcommsServerThread = None
def __init__(self, terminate_request_event, termination_complete_event, reload_request_event, bot_configuration, name, team, index, agent_class_wrapper, agent_metadata_queue, match_config: MatchConfig, matchcomms_root: URL, spawn_id: int): """ :param terminate_request_event: an Event (multiprocessing) which will be set from the outside when the program is trying to terminate :param termination_complete_event: an Event (multiprocessing) which should be set from inside this class when termination has completed successfully :param reload_request_event: an Event (multiprocessing) which will be set from the outside to force a reload of the agent :param reload_complete_event: an Event (multiprocessing) which should be set from inside this class when reloading has completed successfully :param bot_configuration: parameters which will be passed to the bot's constructor :param name: name which will be passed to the bot's constructor. Will probably be displayed in-game. :param team: 0 for blue team or 1 for orange team. Will be passed to the bot's constructor. :param index: The player index, i.e. "this is player number <index>". Will be passed to the bot's constructor. Can be used to pull the correct data corresponding to the bot's car out of the game tick packet. :param agent_class_wrapper: The ExternalClassWrapper object that can be used to load and reload the bot :param agent_metadata_queue: a Queue (multiprocessing) which expects to receive AgentMetadata once available. :param match_config: Describes the match that is being played. :param matchcomms_root: The server to connect to if you want to communicate to other participants in the match. :param spawn_id: The identifier we expect to see in the game tick packet at our player index. If it does not match, then we will force the agent to retire. Pass None to opt out of this behavior. """ self.terminate_request_event = terminate_request_event self.termination_complete_event = termination_complete_event self.reload_request_event = reload_request_event self.bot_configuration = bot_configuration self.name = name self.team = team self.index = index self.agent_class_wrapper = agent_class_wrapper self.agent_metadata_queue = agent_metadata_queue self.logger = get_logger('bot' + str(self.index)) self.game_interface = GameInterface(self.logger) self.last_chat_time = time.time() self.chat_counter = 0 self.reset_chat_time = True self.game_tick_packet = None self.bot_input = None self.ball_prediction = None self.rigid_body_tick = None self.match_config = match_config self.matchcomms_root = matchcomms_root self.last_message_index = 0 self.agent = None self.agent_class_file = None self.last_module_modification_time = 0 self.scan_last = 0 self.scan_temp = 0 self.file_iterator = None self.maximum_tick_rate_preference = bot_configuration.get( BOT_CONFIG_MODULE_HEADER, MAXIMUM_TICK_RATE_PREFERENCE_KEY) self.spawn_id = spawn_id self.spawn_id_seen = False self.counter = 0
def __init__(self): self.logger = get_logger(DEFAULT_LOGGER) self.game_interface = GameInterface(self.logger) self.quick_chat_manager = QuickChatManager(self.game_interface) self.quit_event = mp.Event() self.helper_process_manager = HelperProcessManager(self.quit_event) self.bot_quit_callbacks = [] self.bot_reload_requests = [] self.agent_metadata_map = {} self.ball_prediction_process = None self.match_config: MatchConfig = None
def __init__(self, name): super().__init__(name) self.logger = get_logger(name) self.__key = hash("BaseScript:" + name) self.game_tick_packet = GameTickPacket() self.ball_prediction = BallPrediction() self.game_interface = GameInterface(self.logger) self.game_interface.load_interface() fake_index = random.randint( 100, 10000) # a number unlikely to conflict with bots or other scripts self.renderer = self.game_interface.renderer.get_rendering_manager( bot_index=fake_index, bot_team=2)
def __init__(self, agent_metadata_queue, quit_event, options): super().__init__(agent_metadata_queue, quit_event, options) self.logger = get_logger('scratch_mgr') self.game_interface = GameInterface(self.logger) self.current_sockets = set() self.running_indices = set() self.metadata_map = dict() self.port: int = options['port'] self.sb3_file = options['sb3-file'] self.pretend_blue_team = options['pretend_blue_team'] self.has_received_input = False self.scratch_index_to_rlbot = {} self.should_flip_field = False
def __init__(self, agent_metadata_queue, quit_event, options): super().__init__(agent_metadata_queue, quit_event, options) # Sets up the logger. The string is the name of your hivemind. # Call this something unique so people can differentiate between hiveminds. self.logger = get_logger('Example Hivemind') # The game interface is how you get access to things # like ball prediction, the game tick packet, or rendering. self.game_interface = GameInterface(self.logger) # Running indices is a set of bot indices # which requested this hivemind with the same key. self.running_indices = set()
def __init__(self): self.logger = get_logger(DEFAULT_LOGGER) self.game_interface = GameInterface(self.logger) self.quit_event = mp.Event() self.helper_process_manager = HelperProcessManager(self.quit_event) self.bot_quit_callbacks = [] self.bot_reload_requests = [] self.agent_metadata_map: Dict[int, AgentMetadata] = {} self.match_config: MatchConfig = None self.launcher_preference = None self.rlbot_gateway_process = None self.matchcomms_server: MatchcommsServerThread = None self.early_start_seconds = 0 self.num_metadata_received = 0
def __init__(self, queue, choreo_obj): # Sets up the logger. The string is the name of your hivemind. # Call this something unique so people can differentiate between hiveminds. self.logger = get_logger('Choreography Hivemind') # The game interface is how you get access to things # like ball prediction, the game tick packet, or rendering. self.game_interface = GameInterface(self.logger) self.drones = [] self.choreo = choreo_obj(self.game_interface) self.choreo.generate_sequence(self.drones) # Set up queue to know when to stop and reload. self.queue = queue
def __init__(self, agent_metadata_queue, quit_event, options): super().__init__(agent_metadata_queue, quit_event, options) # Controls. pygame.init() pygame.joystick.init() self.controller = pygame.joystick.Joystick(0) self.controller.init() self.axis_data = [0] * self.controller.get_numaxes() self.button_data = [False] * self.controller.get_numbuttons() # RLBot. self.index = options["index"] self.game_interface = GameInterface(get_logger(str(self.index))) self.recording = False self.recorded = [] self.recording_time = None
def __init__(self): self.game_interface = GameInterface(get_logger("Commentator")) self.game_interface.load_interface() self.game_interface.wait_until_loaded() self.touchTimer = 0 self.currentTime = 0 self.firstIter = True self.overTime = False self.shotDetection = True self.ballHistory = [] self.lastTouches = [] self.teams = [] self.joinTimer = 0 self.q = Queue(maxsize=3) self.host = threading.Thread(target=host, args=(self.q,)) self.host.start() self.main() self.host.join()
def __init__(self, terminate_request_event, termination_complete_event, reload_request_event, bot_configuration, name, team, index, agent_class_wrapper, agent_metadata_queue, match_config: MatchConfig, matchcomms_root: URL): """ :param terminate_request_event: an Event (multiprocessing) which will be set from the outside when the program is trying to terminate :param termination_complete_event: an Event (multiprocessing) which should be set from inside this class when termination has completed successfully :param reload_request_event: an Event (multiprocessing) which will be set from the outside to force a reload of the agent :param reload_complete_event: an Event (multiprocessing) which should be set from inside this class when reloading has completed successfully :param bot_configuration: parameters which will be passed to the bot's constructor :param name: name which will be passed to the bot's constructor. Will probably be displayed in-game. :param team: 0 for blue team or 1 for orange team. Will be passed to the bot's constructor. :param index: The player index, i.e. "this is player number <index>". Will be passed to the bot's constructor. Can be used to pull the correct data corresponding to the bot's car out of the game tick packet. :param agent_class_wrapper: The ExternalClassWrapper object that can be used to load and reload the bot :param agent_metadata_queue: a Queue (multiprocessing) which expects to receive AgentMetadata once available. :param match_config: Describes the match that is being played. :param matchcomms_root: The server to connect to if you want to communicate to other participants in the match. """ self.terminate_request_event = terminate_request_event self.termination_complete_event = termination_complete_event self.reload_request_event = reload_request_event self.bot_configuration = bot_configuration self.name = name self.team = team self.index = index self.agent_class_wrapper = agent_class_wrapper self.agent_metadata_queue = agent_metadata_queue self.logger = get_logger('bot' + str(self.index)) self.game_interface = GameInterface(self.logger) self.last_chat_time = time.time() self.chat_counter = 0 self.reset_chat_time = True self.game_tick_packet = None self.bot_input = None self.ball_prediction = None self.rigid_body_tick = None self.match_config = match_config self.matchcomms_root = matchcomms_root self.last_message_index = 0 self.agent = None self.agent_class_file = None self.last_module_modification_time = 0
def run_state_setting(my_queue: Queue): """Controls state setting for tests.""" message = my_queue.get() if message != Message.READY: raise Exception(f"Got {message} instead of READY") logger = get_logger("UTSS") # Unit Test State Setting game_interface = GameInterface(logger) game_interface.load_interface() game_interface.wait_until_loaded() logger.info("Running!") # Get the first GameState. game_state, message = my_queue.get() game_interface.set_game_state(game_state) while True: while my_queue.qsize() == 0: # Sleep to prevent reset-spamming. time.sleep(0.1) if not keyboard.is_pressed(RESET_KEY): continue # Reset the GameState. logger.info("Resetting test.") game_interface.set_game_state(game_state) # Receive GameState. logger.info("Setting new test.") game_state, message = my_queue.get() if message == Message.DONE: print('Thread 2 closing.') exit() game_interface.set_game_state(game_state)
def __init__(self, agent_metadata_queue, quit_event): super().__init__(agent_metadata_queue, quit_event) self.logger = get_logger('scratch_mgr') self.game_interface = GameInterface(self.logger) self.current_sockets = set()
def __init__(self): self.game_interface = GameInterface(get_logger("observer")) self.game_interface.load_interface() self.game_interface.wait_until_loaded() self.game_interface.set_game_state(GameState(console_commands=[f'Set WorldInfo WorldGravityZ {WORLD_GRAVITY}'])) self.main()
def __init__(self, agent_metadata_queue, quit_event, options): super().__init__(agent_metadata_queue, quit_event, options) self.logger = get_logger('Hivemind') self.game_interface = GameInterface(self.logger) self.running_indices = set()
def __init__(self): self.logger = get_logger('packet reader') self.game_interface = GameInterface(self.logger) self.game_interface.inject_dll() self.game_interface.load_interface() self.game_tick_packet = game_data_struct.GameTickPacket()