コード例 #1
0
ファイル: setup_manager.py プロジェクト: robbai/RLBot
    def run_agent(terminate_event, callback_event, reload_request,
                  bundle: BotConfigBundle, name, team, index, python_file,
                  agent_telemetry_queue, match_config: MatchConfig,
                  matchcomms_root: URL, spawn_id: str):

        agent_class_wrapper = import_agent(python_file)
        config_file = agent_class_wrapper.get_loaded_class(
        ).base_create_agent_configurations()
        config_file.parse_file(bundle.config_obj,
                               config_directory=bundle.config_directory)

        if hasattr(agent_class_wrapper.get_loaded_class(),
                   "run_independently"):
            bm = BotManagerIndependent(terminate_event, callback_event,
                                       reload_request, config_file, name, team,
                                       index, agent_class_wrapper,
                                       agent_telemetry_queue, match_config,
                                       matchcomms_root, spawn_id)
        elif hasattr(agent_class_wrapper.get_loaded_class(),
                     "get_output_flatbuffer"):
            bm = BotManagerFlatbuffer(terminate_event, callback_event,
                                      reload_request, config_file, name, team,
                                      index, agent_class_wrapper,
                                      agent_telemetry_queue, match_config,
                                      matchcomms_root, spawn_id)
        else:
            bm = BotManagerStruct(terminate_event, callback_event,
                                  reload_request, config_file, name, team,
                                  index, agent_class_wrapper,
                                  agent_telemetry_queue, match_config,
                                  matchcomms_root, spawn_id)
        bm.run()
コード例 #2
0
ファイル: presets.py プロジェクト: mgiglia92/RLBots
    def __init__(self, name, file_path=None):

        self.looks_path = None

        if file_path is not None and os.path.isfile(file_path):
            config_bundle = get_bot_config_bundle(file_path)
            self.looks_path = config_bundle.get_absolute_path(
                BOT_CONFIG_MODULE_HEADER, LOOKS_CONFIG_KEY)
            python_file_path = config_bundle.get_absolute_path(
                BOT_CONFIG_MODULE_HEADER, PYTHON_FILE_KEY)

        else:
            python_file_path = inspect.getfile(BaseAgent)

        try:
            self.agent_class = import_agent(
                python_file_path).get_loaded_class()
        except (ValueError, ModuleNotFoundError, FileNotFoundError) as e:
            raise ValueError("Problem when processing {}: {}".format(
                file_path, str(e)))

        super().__init__(self.agent_class.base_create_agent_configurations(),
                         file_path, name)
        # Make sure the path to the python file actually gets set to that path, even if there was no config at file_path
        self.config.set_value(BOT_CONFIG_MODULE_HEADER, PYTHON_FILE_KEY,
                              python_file_path)
コード例 #3
0
    def __init__(self, name, file_path=None):
        basic_config = BaseAgent.base_create_agent_configurations()

        if file_path is not None and os.path.isfile(file_path):
            file_path = os.path.realpath(file_path)
            basic_config.parse_file(file_path)
        else:
            base_agent_path = os.path.join(get_python_root(), "rlbot",
                                           "agents", "base_agent.py")
            try:
                rel_path = os.path.relpath(base_agent_path, get_python_root())
            except ValueError:
                rel_path = base_agent_path
            basic_config.set_value(BOT_CONFIG_MODULE_HEADER, PYTHON_FILE_KEY,
                                   rel_path)

        python_file_path = os.path.realpath(
            os.path.join(
                os.path.dirname(os.path.realpath(file_path)),
                basic_config.get(BOT_CONFIG_MODULE_HEADER, PYTHON_FILE_KEY)))
        try:
            self.agent_class = import_agent(
                python_file_path).get_loaded_class()
        except (ValueError, ModuleNotFoundError):
            self.agent_class = BaseAgent

        super().__init__(self.agent_class.base_create_agent_configurations(),
                         file_path, name)
        # Make sure the path to the python file actually gets set to that path, even if there was no config at file_path
        self.config.set_value(
            BOT_CONFIG_MODULE_HEADER, PYTHON_FILE_KEY,
            basic_config.get(BOT_CONFIG_MODULE_HEADER, PYTHON_FILE_KEY))
コード例 #4
0
ファイル: setup_manager.py プロジェクト: JustinPopl/RLBot
    def run_agent(terminate_event, callback_event, reload_request, config_file,
                  name, team, index, python_file, agent_telemetry_queue,
                  queue_holder, match_config: MatchConfig):

        agent_class_wrapper = import_agent(python_file)

        if hasattr(agent_class_wrapper.get_loaded_class(),
                   "run_independently"):
            bm = BotManagerIndependent(terminate_event, callback_event,
                                       reload_request, config_file, name, team,
                                       index, agent_class_wrapper,
                                       agent_telemetry_queue, queue_holder,
                                       match_config)
        elif hasattr(agent_class_wrapper.get_loaded_class(),
                     "get_output_flatbuffer"):
            bm = BotManagerFlatbuffer(terminate_event, callback_event,
                                      reload_request, config_file, name, team,
                                      index, agent_class_wrapper,
                                      agent_telemetry_queue, queue_holder,
                                      match_config)
        else:
            bm = BotManagerStruct(terminate_event, callback_event,
                                  reload_request, config_file, name, team,
                                  index, agent_class_wrapper,
                                  agent_telemetry_queue, queue_holder,
                                  match_config)
        bm.run()
コード例 #5
0
ファイル: setup_manager.py プロジェクト: 1JJensen/RLBot
    def run_agent(terminate_event, callback_event, reload_request,
                  bundle: BotConfigBundle, name, team, index, python_file,
                  agent_telemetry_queue, match_config: MatchConfig,
                  matchcomms_root: URL, spawn_id: str):

        # Set the working directory to one level above the bot cfg file.
        # This mimics the behavior you get when executing run.py in one of the
        # example bot repositories, so bots will be more likely to 'just work'
        # even if the developer is careless about file paths.
        os.chdir(Path(bundle.config_directory).parent)

        agent_class_wrapper = import_agent(python_file)
        config_file = agent_class_wrapper.get_loaded_class(
        ).base_create_agent_configurations()
        config_file.parse_file(bundle.config_obj,
                               config_directory=bundle.config_directory)

        if hasattr(agent_class_wrapper.get_loaded_class(),
                   "run_independently"):
            bm = BotManagerIndependent(terminate_event, callback_event,
                                       reload_request, config_file, name, team,
                                       index, agent_class_wrapper,
                                       agent_telemetry_queue, match_config,
                                       matchcomms_root, spawn_id)
        else:
            bm = BotManagerStruct(terminate_event, callback_event,
                                  reload_request, config_file, name, team,
                                  index, agent_class_wrapper,
                                  agent_telemetry_queue, match_config,
                                  matchcomms_root, spawn_id)
        bm.run()
コード例 #6
0
ファイル: presets.py プロジェクト: mgiglia92/RLBots
 def load_agent_class(self, python_file_path):
     result = True
     self.agent_class = import_agent(python_file_path).get_loaded_class()
     old_config = self.config.copy()
     self.config = self.agent_class.base_create_agent_configurations()
     self.config.parse_file(old_config)
     return result
コード例 #7
0
    def __init__(self, name, file_path=None):

        self.looks_path = None
        self.logger = get_logger('agent_preset')

        if file_path is not None and os.path.isfile(file_path):
            config_bundle = get_bot_config_bundle(file_path)
            self.looks_path = config_bundle.get_absolute_path(
                BOT_CONFIG_MODULE_HEADER, LOOKS_CONFIG_KEY)
            python_file_path = config_bundle.get_absolute_path(
                BOT_CONFIG_MODULE_HEADER, PYTHON_FILE_KEY)

        else:
            python_file_path = inspect.getfile(BaseAgent)

        try:
            self.agent_class = import_agent(
                python_file_path).get_loaded_class()
            super().__init__(
                self.agent_class.base_create_agent_configurations(), file_path,
                name)
        except (ValueError, ModuleNotFoundError, FileNotFoundError) as e:
            raise ValueError(f"Problem when processing {file_path}: {str(e)}")
        except ImportError as e:
            self.logger.debug(
                f"Will not use custom config for {file_path} because we failed to load: {str(e)}"
            )
            super().__init__(BaseAgent.base_create_agent_configurations(),
                             file_path, name)

        # Make sure the path to the python file actually gets set to that path, even if there was no config at file_path
        self.config.set_value(BOT_CONFIG_MODULE_HEADER, PYTHON_FILE_KEY,
                              python_file_path)
コード例 #8
0
ファイル: setup_manager.py プロジェクト: m0re4u/RLBot
    def run_agent(terminate_event, callback_event, reload_request, config_file, name, team, index, python_file,
                  agent_telemetry_queue, agent_state_queue, queue_holder, match_config: MatchConfig):

        agent_class_wrapper = import_agent(python_file)
        bm = BotManagerStruct(terminate_event, callback_event, reload_request, config_file, name, team, index,
                                agent_class_wrapper, agent_telemetry_queue, queue_holder, match_config, agent_state_queue)
        bm.run()
コード例 #9
0
def load_bot_config(index, bot_configuration, config_bundle: BotConfigBundle,
                    looks_config_object, overall_config, name_dict,
                    human_index_tracker: IncrementingInteger):
    """
    Loads the config data of a single bot
    :param index: This is the bot index (where it appears in game_cars)
    :param bot_configuration: This is the game_tick_packet configuration that is sent back to the game
    :param config_bundle: A config object for a single bot
    :param overall_config: This is the config for the entire session not one particular bot
    :param name_dict: A mapping of used names so we can make sure to not reuse bot names.
    :param human_index_tracker: An object of type HumanIndexManager that helps set human_index correctly.
    :return:
    """
    team_num = get_team(overall_config, index)

    bot_configuration.team = team_num

    # Setting up data about what type of bot it is
    bot_type = overall_config.get(PARTICIPANT_CONFIGURATION_HEADER,
                                  PARTICIPANT_TYPE_KEY, index)
    bot_configuration.bot, bot_configuration.rlbot_controlled = get_bot_options(
        bot_type)
    bot_configuration.bot_skill = overall_config.getfloat(
        PARTICIPANT_CONFIGURATION_HEADER, PARTICIPANT_BOT_SKILL_KEY, index)

    if not bot_configuration.bot:
        bot_configuration.human_index = human_index_tracker.increment()

    loadout_header = BOT_CONFIG_LOADOUT_HEADER
    if team_num == 1 and looks_config_object.has_section(
            BOT_CONFIG_LOADOUT_ORANGE_HEADER):
        loadout_header = BOT_CONFIG_LOADOUT_ORANGE_HEADER

    # Setting up the bots name
    bot_name = config_bundle.config_obj.get(BOT_CONFIG_MODULE_HEADER,
                                            BOT_NAME_KEY)
    bot_configuration.name = get_sanitized_bot_name(name_dict, bot_name)

    BaseAgent._parse_bot_loadout(bot_configuration, looks_config_object,
                                 loadout_header)

    python_file = 'NO_MODULE_FOR_PARTICIPANT'
    bot_parameters = None

    if bot_configuration.rlbot_controlled:
        # Python file relative to the config location.
        python_file = config_bundle.get_absolute_path(BOT_CONFIG_MODULE_HEADER,
                                                      PYTHON_FILE_KEY)
        agent_class_wrapper = import_agent(python_file)
        bot_parameters = agent_class_wrapper.get_loaded_class(
        ).base_create_agent_configurations()
        bot_parameters.parse_file(
            config_bundle.config_obj,
            config_directory=config_bundle.config_directory)

    return bot_name, team_num, python_file, bot_parameters
コード例 #10
0
 def load_agent_class(self, python_file_path):
     result = True
     try:
         self.agent_class = import_agent(
             python_file_path).get_loaded_class()
     except (ValueError, ModuleNotFoundError):
         self.agent_class = BaseAgent
         result = False
     old_config = self.config.copy()
     self.config = self.agent_class.base_create_agent_configurations()
     self.config.parse_file(old_config)
     return result
コード例 #11
0
ファイル: setup_manager.py プロジェクト: m0re4u/RLBot
def load_bot_parameters(config_bundle) -> ConfigObject:
    """
    Initializes the agent in the bundle's python file and asks it to provide its
    custom configuration object where its parameters can be set.
    :return: the parameters as a ConfigObject
    """
    # Python file relative to the config location.
    python_file = config_bundle.python_file
    agent_class_wrapper = import_agent(python_file)
    bot_parameters = agent_class_wrapper.get_loaded_class().base_create_agent_configurations()
    bot_parameters.parse_file(config_bundle.config_obj, config_directory=config_bundle.config_directory)
    return bot_parameters
コード例 #12
0
ファイル: invisibot.py プロジェクト: Supersilver10/RLBotPack
"""
Invisibot is a rocket league bot based on RLBot framework.
It uses an internals of a different bot and adds
hiding/unhiding as appropriate.
"""

from os import path

from rlbot.utils.class_importer import import_agent

botlib = import_agent(path.abspath('../Kamael/Kamael.py'))
BaseBot = botlib.get_loaded_class()

from rlbot.agents.base_agent import SimpleControllerState
from rlbot.utils.structures.game_data_struct import GameTickPacket
from rlbot.utils.game_state_util import GameState, CarState, Physics, Vector3, Rotator

from car_simulation_by_controls import SimPhysics, CarSimmer, Vec3

DEBUG = False
PROXIMITY = 1000

# To implement list:
# - Reset between goals
# - If simulation stuck in same location for multiple ticks, unhide
# - Boost tracking

# Import appropriate bot as BaseBot
class InvisibotWrapper(BaseBot):
    def __init__(self, name, team, index):
        super().__init__(name, team, index)