├── scratch_bot ├── __init__.py ├── my_scratch_bot.sb3 ├── scratch_bot.py ├── appearance.cfg ├── appearance2.cfg ├── my_scratch_bot.cfg └── other_colors_bot.cfg ├── .gitignore ├── README.md ├── run.bat ├── requirements.txt ├── LICENSE ├── run.py ├── RefreshEnv.cmd └── rlbot.cfg /scratch_bot/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .idea/ 2 | __pycache__/ 3 | *.iml 4 | pyvjoy/ -------------------------------------------------------------------------------- /scratch_bot/my_scratch_bot.sb3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RLBot/RLBotScratchInterface/HEAD/scratch_bot/my_scratch_bot.sb3 -------------------------------------------------------------------------------- /scratch_bot/scratch_bot.py: -------------------------------------------------------------------------------- 1 | from rlbot.agents.base_scratch_agent import BaseScratchAgent 2 | 3 | 4 | class ScratchBot(BaseScratchAgent): 5 | pass 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # RLBotScratchInterface 2 | Allows the Scratch programming language to control RLBot. 3 | 4 | ## Quick Start 5 | 6 | - Follow this guide to install RLBot and start a Scratch bot: https://youtu.be/ZL896rI-KrU 7 | - Get some tips here: https://youtu.be/c6rsBEqx22c 8 | -------------------------------------------------------------------------------- /run.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | @rem Change the working directory to the location of this file so that relative paths will work 4 | cd /D "%~dp0" 5 | 6 | @rem Make sure the environment variables are up-to-date. This is useful if the user installed python a moment ago. 7 | call .\RefreshEnv.cmd 8 | 9 | python run.py 10 | 11 | pause 12 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | # The main rlbot framework 2 | # You will automatically get updates for all versions starting with "1.". 3 | rlbot==1.* 4 | 5 | # Used to allow python to communicate with the browser that's running scratch 6 | websockets 7 | 8 | # Used to automatically launch web browsers and run the scratch code on them 9 | selenium 10 | 11 | # Provides an up-to-date version of chromedriver.exe to assist selenium 12 | webdriver_manager 13 | 14 | # This will cause pip to auto-upgrade and stop scaring people with warning messages 15 | pip 16 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /run.py: -------------------------------------------------------------------------------- 1 | import subprocess 2 | import sys 3 | 4 | DEFAULT_LOGGER = 'rlbot' 5 | 6 | if __name__ == '__main__': 7 | 8 | try: 9 | from rlbot.utils import public_utils, logging_utils 10 | 11 | logger = logging_utils.get_logger(DEFAULT_LOGGER) 12 | if not public_utils.have_internet(): 13 | logger.log(logging_utils.logging_level, 14 | 'Skipping upgrade check for now since it looks like you have no internet') 15 | elif public_utils.is_safe_to_upgrade(): 16 | subprocess.call([sys.executable, "-m", "pip", "install", '-r', 'requirements.txt']) 17 | subprocess.call([sys.executable, "-m", "pip", "install", 'rlbot', '--upgrade']) 18 | 19 | # https://stackoverflow.com/a/44401013 20 | rlbots = [module for module in sys.modules if module.startswith('rlbot')] 21 | for rlbot_module in rlbots: 22 | sys.modules.pop(rlbot_module) 23 | 24 | except ImportError: 25 | subprocess.call([sys.executable, "-m", "pip", "install", '-r', 'requirements.txt', '--upgrade', '--upgrade-strategy=eager']) 26 | 27 | try: 28 | from rlbot import runner 29 | runner.main() 30 | except Exception as e: 31 | print("Encountered exception: ", e) 32 | print("Press enter to close.") 33 | input() 34 | -------------------------------------------------------------------------------- /scratch_bot/appearance.cfg: -------------------------------------------------------------------------------- 1 | [Bot Loadout] 2 | # Primary Color selection 3 | team_color_id = 30 4 | # Secondary Color selection 5 | custom_color_id = 95 6 | # Car type (Octane, Merc, etc 7 | car_id = 23 8 | # Type of decal 9 | decal_id = 305 10 | # Wheel selection 11 | wheels_id = 363 12 | # Boost selection 13 | boost_id = 38 14 | # Antenna Selection 15 | antenna_id = 14 16 | # Hat Selection 17 | hat_id = 0 18 | # Paint Type (for first color) 19 | paint_finish_id = 276 20 | # Paint Type (for secondary color) 21 | custom_finish_id = 276 22 | # Engine Audio Selection 23 | engine_audio_id = 0 24 | # Car trail Selection 25 | trails_id = 0 26 | # Goal Explosion Selection 27 | goal_explosion_id = 1969 28 | 29 | [Bot Loadout Orange] 30 | # Primary Color selection 31 | team_color_id = 39 32 | # Secondary Color selection 33 | custom_color_id = 12 34 | # Car type (Octane, Merc, etc 35 | car_id = 523 36 | # Type of decal 37 | decal_id = 583 38 | # Wheel selection 39 | wheels_id = 376 40 | # Boost selection 41 | boost_id = 48 42 | # Antenna Selection 43 | antenna_id = 8 44 | # Hat Selection 45 | hat_id = 0 46 | # Paint Type (for first color) 47 | paint_finish_id = 2066 48 | # Paint Type (for secondary color) 49 | custom_finish_id = 2066 50 | # Engine Audio Selection 51 | engine_audio_id = 0 52 | # Car trail Selection 53 | trails_id = 0 54 | # Goal Explosion Selection 55 | goal_explosion_id = 1971 56 | 57 | -------------------------------------------------------------------------------- /scratch_bot/appearance2.cfg: -------------------------------------------------------------------------------- 1 | [Bot Loadout] 2 | # Primary Color selection 3 | team_color_id = 58 4 | # Secondary Color selection 5 | custom_color_id = 0 6 | # Car type (Octane, Merc, etc 7 | car_id = 403 8 | # Type of decal 9 | decal_id = 508 10 | # Wheel selection 11 | wheels_id = 365 12 | # Boost selection 13 | boost_id = 1093 14 | # Antenna Selection 15 | antenna_id = 16 16 | # Hat Selection 17 | hat_id = 0 18 | # Paint Type (for first color) 19 | paint_finish_id = 274 20 | # Paint Type (for secondary color) 21 | custom_finish_id = 274 22 | # Engine Audio Selection 23 | engine_audio_id = 0 24 | # Car trail Selection 25 | trails_id = 0 26 | # Goal Explosion Selection 27 | goal_explosion_id = 1907 28 | 29 | [Bot Loadout Orange] 30 | # Primary Color selection 31 | team_color_id = 34 32 | # Secondary Color selection 33 | custom_color_id = 0 34 | # Car type (Octane, Merc, etc 35 | car_id = 402 36 | # Type of decal 37 | decal_id = 497 38 | # Wheel selection 39 | wheels_id = 364 40 | # Boost selection 41 | boost_id = 2394 42 | # Antenna Selection 43 | antenna_id = 755 44 | # Hat Selection 45 | hat_id = 0 46 | # Paint Type (for first color) 47 | paint_finish_id = 274 48 | # Paint Type (for secondary color) 49 | custom_finish_id = 274 50 | # Engine Audio Selection 51 | engine_audio_id = 0 52 | # Car trail Selection 53 | trails_id = 0 54 | # Goal Explosion Selection 55 | goal_explosion_id = 2702 56 | 57 | -------------------------------------------------------------------------------- /scratch_bot/my_scratch_bot.cfg: -------------------------------------------------------------------------------- 1 | [Locations] 2 | # Path to loadout config. Can use relative path from here. 3 | looks_config = ./appearance.cfg 4 | 5 | # Path to python file. Can use relative path from here. 6 | python_file = ./scratch_bot.py 7 | 8 | # Name of the bot in-game 9 | name = ScratchBot 10 | 11 | # Your scratch bot will start running early before the match fully launches, to give it more time. 12 | supports_early_start = True 13 | 14 | [Bot Parameters] 15 | # The port to use when connecting Scratch to RLBot. Should be unique from all other bots. 16 | port = 42008 17 | 18 | # We will automatically launch a browser with the correct settings to run your bot. 19 | spawn_browser = True 20 | 21 | # The location of the Scratch file containing your bot. 22 | sb3file = my_scratch_bot.sb3 23 | 24 | # The bot will run in an invisible browser. 25 | headless = False 26 | 27 | # If you spawn multiple bots, each will get its own separate browser instance and pretend to be player 1. 28 | separate_browsers = False 29 | 30 | # If your bots in the browser all on orange, we will pretend in Scratch that they're on the blue team. 31 | pretend_blue_team = True 32 | 33 | [Details] 34 | # These values are optional but useful metadata for helper programs 35 | # Name of the bot's creator/developer 36 | developer = The RLBot community 37 | 38 | # Short description of the bot 39 | description = This is a multi-line description 40 | of the official scratch example bot 41 | 42 | # Fun fact about the bot 43 | fun_fact = 44 | 45 | # Link to github repository 46 | github = https://github.com/RLBot/RLBotScratchInterface 47 | 48 | # Programming language 49 | language = scratch 50 | -------------------------------------------------------------------------------- /scratch_bot/other_colors_bot.cfg: -------------------------------------------------------------------------------- 1 | [Locations] 2 | # Path to loadout config. Can use relative path from here. 3 | looks_config = ./appearance2.cfg 4 | 5 | # Path to python file. Can use relative path from here. 6 | python_file = ./scratch_bot.py 7 | 8 | # Name of the bot in-game 9 | name = ScratchBot 10 | 11 | # Your scratch bot will start running early before the match fully launches, to give it more time. 12 | supports_early_start = True 13 | 14 | [Bot Parameters] 15 | # The port to use when connecting Scratch to RLBot. Should be unique from all other bots. 16 | port = 42008 17 | 18 | # We will automatically launch a browser with the correct settings to run your bot. 19 | spawn_browser = True 20 | 21 | # The location of the Scratch file containing your bot. 22 | sb3file = my_scratch_bot.sb3 23 | 24 | # The bot will run in an invisible browser. 25 | headless = False 26 | 27 | # If you spawn multiple bots, each will get its own separate browser instance and pretend to be player 1. 28 | separate_browsers = False 29 | 30 | # If your bots in the browser all on orange, we will pretend in Scratch that they're on the blue team. 31 | pretend_blue_team = True 32 | 33 | [Details] 34 | # These values are optional but useful metadata for helper programs 35 | # Name of the bot's creator/developer 36 | developer = The RLBot community 37 | 38 | # Short description of the bot 39 | description = This is a multi-line description 40 | of the official scratch example bot 41 | 42 | # Fun fact about the bot 43 | fun_fact = 44 | 45 | # Link to github repository 46 | github = https://github.com/RLBot/RLBotScratchInterface 47 | 48 | # Programming language 49 | language = scratch 50 | -------------------------------------------------------------------------------- /RefreshEnv.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | :: This file is taken from chocolatey: 3 | :: https://github.com/chocolatey/choco/blob/master/src/chocolatey.resources/redirects/RefreshEnv.cmd 4 | :: 5 | :: RefreshEnv.cmd 6 | :: 7 | :: Batch file to read environment variables from registry and 8 | :: set session variables to these values. 9 | :: 10 | :: With this batch file, there should be no need to reload command 11 | :: environment every time you want environment changes to propagate 12 | 13 | ::echo "RefreshEnv.cmd only works from cmd.exe, please install the Chocolatey Profile to take advantage of refreshenv from PowerShell" 14 | echo | set /p dummy="Refreshing environment variables from registry for cmd.exe. Please wait..." 15 | 16 | goto main 17 | 18 | :: Set one environment variable from registry key 19 | :SetFromReg 20 | "%WinDir%\System32\Reg" QUERY "%~1" /v "%~2" > "%TEMP%\_envset.tmp" 2>NUL 21 | for /f "usebackq skip=2 tokens=2,*" %%A IN ("%TEMP%\_envset.tmp") do ( 22 | echo/set "%~3=%%B" 23 | ) 24 | goto :EOF 25 | 26 | :: Get a list of environment variables from registry 27 | :GetRegEnv 28 | "%WinDir%\System32\Reg" QUERY "%~1" > "%TEMP%\_envget.tmp" 29 | for /f "usebackq skip=2" %%A IN ("%TEMP%\_envget.tmp") do ( 30 | if /I not "%%~A"=="Path" ( 31 | call :SetFromReg "%~1" "%%~A" "%%~A" 32 | ) 33 | ) 34 | goto :EOF 35 | 36 | :main 37 | echo/@echo off >"%TEMP%\_env.cmd" 38 | 39 | :: Slowly generating final file 40 | call :GetRegEnv "HKLM\System\CurrentControlSet\Control\Session Manager\Environment" >> "%TEMP%\_env.cmd" 41 | call :GetRegEnv "HKCU\Environment">>"%TEMP%\_env.cmd" >> "%TEMP%\_env.cmd" 42 | 43 | :: Special handling for PATH - mix both User and System 44 | call :SetFromReg "HKLM\System\CurrentControlSet\Control\Session Manager\Environment" Path Path_HKLM >> "%TEMP%\_env.cmd" 45 | call :SetFromReg "HKCU\Environment" Path Path_HKCU >> "%TEMP%\_env.cmd" 46 | 47 | :: Caution: do not insert space-chars before >> redirection sign 48 | echo/set "Path=%%Path_HKLM%%;%%Path_HKCU%%" >> "%TEMP%\_env.cmd" 49 | 50 | :: Cleanup 51 | del /f /q "%TEMP%\_envset.tmp" 2>nul 52 | del /f /q "%TEMP%\_envget.tmp" 2>nul 53 | 54 | :: capture user / architecture 55 | SET "OriginalUserName=%USERNAME%" 56 | SET "OriginalArchitecture=%PROCESSOR_ARCHITECTURE%" 57 | 58 | :: Set these variables 59 | call "%TEMP%\_env.cmd" 60 | 61 | :: reset user / architecture 62 | SET "USERNAME=%OriginalUserName%" 63 | SET "PROCESSOR_ARCHITECTURE=%OriginalArchitecture%" 64 | 65 | echo | set /p dummy="Finished." 66 | echo . -------------------------------------------------------------------------------- /rlbot.cfg: -------------------------------------------------------------------------------- 1 | [RLBot Configuration] 2 | # Visit https://github.com/RLBot/RLBot/wiki/Config-File-Documentation to see what you can put here. 3 | 4 | [Team Configuration] 5 | # Visit https://github.com/RLBot/RLBot/wiki/Config-File-Documentation to see what you can put here. 6 | 7 | [Match Configuration] 8 | # Number of bots/players which will be spawned. We support up to max 64. 9 | num_participants = 4 10 | game_mode = Soccer 11 | game_map = Mannfield 12 | 13 | [Mutator Configuration] 14 | # Visit https://github.com/RLBot/RLBot/wiki/Config-File-Documentation to see what you can put here. 15 | Boost Amount = Unlimited 16 | Match Length = Unlimited 17 | 18 | [Participant Configuration] 19 | # Put the name of your bot config file here. Only num_participants config files will be read! 20 | # Everything needs a config, even players and default bots. We still set loadouts and names from config! 21 | participant_config_0 = scratch_bot/my_scratch_bot.cfg 22 | participant_config_1 = scratch_bot/other_colors_bot.cfg 23 | participant_config_2 = scratch_bot/my_scratch_bot.cfg 24 | participant_config_3 = scratch_bot/other_colors_bot.cfg 25 | participant_config_4 = scratch_bot/my_scratch_bot.cfg 26 | participant_config_5 = scratch_bot/my_scratch_bot.cfg 27 | participant_config_6 = scratch_bot/my_scratch_bot.cfg 28 | participant_config_7 = scratch_bot/my_scratch_bot.cfg 29 | participant_config_8 = scratch_bot/my_scratch_bot.cfg 30 | participant_config_9 = scratch_bot/my_scratch_bot.cfg 31 | 32 | # team 0 shoots on positive goal, team 1 shoots on negative goal 33 | participant_team_0 = 0 34 | participant_team_1 = 0 35 | participant_team_2 = 1 36 | participant_team_3 = 1 37 | participant_team_4 = 0 38 | participant_team_5 = 1 39 | participant_team_6 = 0 40 | participant_team_7 = 1 41 | participant_team_8 = 0 42 | participant_team_9 = 1 43 | 44 | # Accepted values are "human", "rlbot", "psyonix", and "party_member_bot" 45 | # You can have up to 4 local players and they must be activated in game or it will crash. 46 | # If no player is specified you will be spawned in as spectator! 47 | # human - not controlled by the framework 48 | # rlbot - controlled by the framework 49 | # psyonix - default bots (skill level can be changed with participant_bot_skill 50 | # party_member_bot - controlled by the framework but the game detects it as a human 51 | participant_type_0 = rlbot 52 | participant_type_1 = rlbot 53 | participant_type_2 = rlbot 54 | participant_type_3 = rlbot 55 | participant_type_4 = rlbot 56 | participant_type_5 = rlbot 57 | participant_type_6 = rlbot 58 | participant_type_7 = rlbot 59 | participant_type_8 = rlbot 60 | participant_type_9 = rlbot 61 | 62 | 63 | # If participant is a bot and not RLBot controlled, this value will be used to set bot skill. 64 | # 0.0 is Rookie, 0.5 is pro, 1.0 is all-star. You can set values in-between as well. 65 | # Please leave a value here even if it isn't used :) 66 | participant_bot_skill_0 = 1.0 67 | participant_bot_skill_1 = 1.0 68 | participant_bot_skill_2 = 1.0 69 | participant_bot_skill_3 = 1.0 70 | participant_bot_skill_4 = 1.0 71 | participant_bot_skill_5 = 1.0 72 | participant_bot_skill_6 = 1.0 73 | participant_bot_skill_7 = 1.0 74 | participant_bot_skill_8 = 1.0 75 | participant_bot_skill_9 = 1.0 76 | --------------------------------------------------------------------------------