From 65bfbb2d2951d98e18ba3ee73332d5a66d7fbc6e Mon Sep 17 00:00:00 2001 From: Tyler Arehart Date: Thu, 21 Nov 2019 18:44:39 -0800 Subject: [PATCH 1/6] Settings for testing remote rlbot. --- rlbot.cfg | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/rlbot.cfg b/rlbot.cfg index b8553d8..00d275b 100644 --- a/rlbot.cfg +++ b/rlbot.cfg @@ -1,14 +1,17 @@ [RLBot Configuration] # Visit https://github.com/RLBot/RLBot/wiki/Config-File-Documentation to see what you can put here. +networking_role = remote_rlbot_client +network_address = 192.168.56.1 [Team Configuration] # Visit https://github.com/RLBot/RLBot/wiki/Config-File-Documentation to see what you can put here. [Match Configuration] # Number of bots/players which will be spawned. We support up to max 10. -num_participants = 2 +num_participants = 1 game_mode = Soccer game_map = Mannfield +existing_match_behavior = Continue And Spawn [Mutator Configuration] # Visit https://github.com/RLBot/RLBot/wiki/Config-File-Documentation to see what you can put here. From ba46996cb95fb2b87caa4cfe156c92397b5ce509 Mon Sep 17 00:00:00 2001 From: Tyler Arehart Date: Thu, 21 Nov 2019 19:40:18 -0800 Subject: [PATCH 2/6] New IP address. --- rlbot.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rlbot.cfg b/rlbot.cfg index 00d275b..06f5872 100644 --- a/rlbot.cfg +++ b/rlbot.cfg @@ -1,7 +1,7 @@ [RLBot Configuration] # Visit https://github.com/RLBot/RLBot/wiki/Config-File-Documentation to see what you can put here. networking_role = remote_rlbot_client -network_address = 192.168.56.1 +network_address = 10.186.111.200 [Team Configuration] # Visit https://github.com/RLBot/RLBot/wiki/Config-File-Documentation to see what you can put here. From dd5277ca77b97c19b0c4f2077b06e104620985ef Mon Sep 17 00:00:00 2001 From: Tyler Arehart Date: Thu, 21 Nov 2019 19:49:01 -0800 Subject: [PATCH 3/6] Newer ip address. --- rlbot.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rlbot.cfg b/rlbot.cfg index 06f5872..02b5cf3 100644 --- a/rlbot.cfg +++ b/rlbot.cfg @@ -1,7 +1,7 @@ [RLBot Configuration] # Visit https://github.com/RLBot/RLBot/wiki/Config-File-Documentation to see what you can put here. networking_role = remote_rlbot_client -network_address = 10.186.111.200 +network_address = 192.168.43.45 [Team Configuration] # Visit https://github.com/RLBot/RLBot/wiki/Config-File-Documentation to see what you can put here. From f72b490584a8c64d430777fb5038f470db59fb08 Mon Sep 17 00:00:00 2001 From: Tyler Arehart Date: Tue, 3 Dec 2019 00:37:15 -0800 Subject: [PATCH 4/6] Simplifying the example bot for remote-rlbot purposes. --- README.md | 55 +++++++++++++++++------------------ requirements.txt | 5 +--- rlbot.cfg | 2 +- src/bot.cfg | 2 +- src/bot.py | 74 ++++++++++++++++++++++++++++-------------------- 5 files changed, 72 insertions(+), 66 deletions(-) diff --git a/README.md b/README.md index 3771948..9d4bed4 100644 --- a/README.md +++ b/README.md @@ -1,30 +1,27 @@ # RLBotPythonExample -Example of a python bot using the RLBot framework - -## Quick Start -The easiest way to start a python bot is demonstrated here! -https://youtu.be/YJ69QZ-EX7k - -It shows you how to: -- Install the RLBot GUI -- Use it to create a new bot - -## Changing the bot - -- Bot behavior is controlled by `src/bot.py` -- Bot appearance is controlled by `src/appearance.cfg` - -See https://github.com/RLBot/RLBotPythonExample/wiki for documentation and tutorials. - -### Older Setup Technique - -**Please don't do this unless you've followed the quick start video and it doesn't work!** - -https://www.youtube.com/watch?v=UjsQFNN0nSA - -1. Make sure you've installed [Python 3.7 64 bit](https://www.python.org/ftp/python/3.7.4/python-3.7.4-amd64.exe). During installation: - - Select "Add Python to PATH" - - Make sure pip is included in the installation -1. Download or clone this repository -1. In the files from the previous step, find and double click on run-gui.bat -1. Click the 'Run' button +Example of a python bot using the RLBot framework, and customized for use +in a classroom setting. + +## Getting Started + +These instructions assume that you're attending some kind of session where +somebody is explaining RLBot and hosting the game on one main computer. + +1. Make sure you have python 3.6 or higher installed. +1. Download this repository. +1. Look in the rlbot.cfg file and make sure the `network_address` +matches what the person hosting has provided. +1. Look in the src/bot.cfg file and change the name "AnonymousBot" to something +you can recognize, so you'll know which car on the screen is yours. +1. Connect to the wireless network called RLBot. The person hosting can tell you the password. +1. Run the program. This should cause a car to appear in the game on the host computer! + - Windows: Double click on run.bat + - Mac / Linux: Open a terminal at this folder location and run `python3 run.py` +1. Open the src/bot.py file in your favorite code editor and start tinkering. +The behavior of the car should change immediately every time you save. + +## Advanced + +- Read about the data available at https://github.com/RLBot/RLBotPythonExample/wiki/Input-and-Output-Data +- Find useful constants at https://github.com/RLBot/RLBot/wiki/Useful-Game-Values +- Make your car beautiful with `src/appearance.cfg` and https://github.com/RLBot/RLBot/wiki/Bot-Customization diff --git a/requirements.txt b/requirements.txt index 25c0c97..c6028b2 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,4 @@ # Include everything the framework requires # You will automatically get updates for all versions starting with "1.". rlbot==1.* -rlbottraining - -# This will cause pip to auto-upgrade and stop scaring people with warning messages -pip +quicktracer diff --git a/rlbot.cfg b/rlbot.cfg index 02b5cf3..d2f1393 100644 --- a/rlbot.cfg +++ b/rlbot.cfg @@ -1,7 +1,7 @@ [RLBot Configuration] # Visit https://github.com/RLBot/RLBot/wiki/Config-File-Documentation to see what you can put here. networking_role = remote_rlbot_client -network_address = 192.168.43.45 +network_address = 192.168.1.100 [Team Configuration] # Visit https://github.com/RLBot/RLBot/wiki/Config-File-Documentation to see what you can put here. diff --git a/src/bot.cfg b/src/bot.cfg index c27f0fb..fef9d88 100644 --- a/src/bot.cfg +++ b/src/bot.cfg @@ -6,7 +6,7 @@ looks_config = ./appearance.cfg python_file = ./bot.py # Name of the bot in-game -name = PythonExampleBot +name = AnonymousBot [Details] # These values are optional but useful metadata for helper programs diff --git a/src/bot.py b/src/bot.py index 58511a2..98aa525 100644 --- a/src/bot.py +++ b/src/bot.py @@ -1,5 +1,6 @@ import math +from quicktracer import trace from rlbot.agents.base_agent import BaseAgent, SimpleControllerState from rlbot.utils.structures.game_data_struct import GameTickPacket @@ -9,38 +10,58 @@ class MyBot(BaseAgent): - def initialize_agent(self): - # This runs once before the bot starts up - self.controller_state = SimpleControllerState() - def get_output(self, packet: GameTickPacket) -> SimpleControllerState: - ball_location = Vec3(packet.game_ball.physics.location) - my_car = packet.game_cars[self.index] car_location = Vec3(my_car.physics.location) + ball_location = Vec3(packet.game_ball.physics.location) - car_to_ball = ball_location - car_location + # trace makes a pretty graph of whatever numeric variable you pass + trace(car_location.dist(ball_location)) - # Find the direction of our car using the Orientation class - car_orientation = Orientation(my_car.physics.rotation) - car_direction = car_orientation.forward + # Numbers taken from https://github.com/RLBot/RLBot/wiki/Useful-Game-Values + enemy_goal_y_value = 5200 if my_car.team == 0 else -5200 + enemy_goal_location = Vec3(0, enemy_goal_y_value, 0) - steer_correction_radians = find_correction(car_direction, car_to_ball) + target = ball_location - if steer_correction_radians > 0: - # Positive radians in the unit circle is a turn to the left. - turn = -1.0 # Negative value for a turn to the left. - action_display = "turn left" - else: - turn = 1.0 - action_display = "turn right" + controller_state = SimpleControllerState() + controller_state.throttle = 1.0 # Positive throttle drives forward, negative drives backward + controller_state.steer = steer_toward_target(my_car, target) + + # controller_state.boost = True # Use boost to go fast or fly + # controller_state.use_item = True # Use item to retract your spikes and release the ball + # controller_state.handbrake = True # Use the handbrake to slide and turn sharply + # controller_state.jump = True # The car will jump when this *transitions* from False to True - self.controller_state.throttle = 1.0 - self.controller_state.steer = turn + # These tilt the car when it's in mid-air + # controller_state.pitch = 0.0 + # controller_state.yaw = 0.0 + # controller_state.roll = 0.0 - draw_debug(self.renderer, my_car, packet.game_ball, action_display) + return controller_state - return self.controller_state + def initialize_agent(self): + # This runs once before the bot starts up + pass + + +def steer_toward_target(my_car, target): + car_location = Vec3(my_car.physics.location) + car_to_target = target - car_location + car_orientation = Orientation(my_car.physics.rotation) + car_direction = car_orientation.forward + steer_correction_radians = find_correction(car_direction, car_to_target) + # A negative steer value turns the car left, which happens to be positive radians, so we invert + # the value here. Also multiplying by a constant to steer more sharply. Max range for steering is -1 to 1. + return clamp(-4 * steer_correction_radians, -1.0, 1.0) + + +def clamp(value, minimum, maximum): + if value > maximum: + return maximum + if value < minimum: + return minimum + return value def find_correction(current: Vec3, ideal: Vec3) -> float: @@ -60,12 +81,3 @@ def find_correction(current: Vec3, ideal: Vec3) -> float: diff -= 2 * math.pi return diff - - -def draw_debug(renderer, car, ball, action_display): - renderer.begin_rendering() - # draw a line from the car to the ball - renderer.draw_line_3d(car.physics.location, ball.physics.location, renderer.white()) - # print the action that the bot is taking - renderer.draw_string_3d(car.physics.location, 2, 2, action_display, renderer.white()) - renderer.end_rendering() From 7b02fb4dd7039b52d1bb87fb76210de769295378 Mon Sep 17 00:00:00 2001 From: Tyler Date: Tue, 3 Dec 2019 23:42:49 -0800 Subject: [PATCH 5/6] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9d4bed4..76c2cd5 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ These instructions assume that you're attending some kind of session where somebody is explaining RLBot and hosting the game on one main computer. 1. Make sure you have python 3.6 or higher installed. -1. Download this repository. +1. Download this specific branch of the repository: https://github.com/RLBot/RLBotPythonExample/zipball/puppy. Make sure you unzip if necessary. 1. Look in the rlbot.cfg file and make sure the `network_address` matches what the person hosting has provided. 1. Look in the src/bot.cfg file and change the name "AnonymousBot" to something From 5f072e0a03fb35a2b4d1e7e61adb20076ddf5efc Mon Sep 17 00:00:00 2001 From: Tyler Arehart Date: Wed, 4 Dec 2019 00:34:52 -0800 Subject: [PATCH 6/6] Setting up spike rush mode. --- .gitignore | 3 ++- requirements.txt | 1 - rlbot.cfg | 10 +++++++--- src/bot.py | 4 ---- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.gitignore b/.gitignore index 51410e9..7aa96bb 100644 --- a/.gitignore +++ b/.gitignore @@ -108,4 +108,5 @@ ENV/ /build # Gradle files -/.gradle \ No newline at end of file +/.gradle +.vscode diff --git a/requirements.txt b/requirements.txt index c6028b2..eb66004 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,3 @@ # Include everything the framework requires # You will automatically get updates for all versions starting with "1.". rlbot==1.* -quicktracer diff --git a/rlbot.cfg b/rlbot.cfg index d2f1393..b140ae2 100644 --- a/rlbot.cfg +++ b/rlbot.cfg @@ -1,6 +1,6 @@ [RLBot Configuration] # Visit https://github.com/RLBot/RLBot/wiki/Config-File-Documentation to see what you can put here. -networking_role = remote_rlbot_client +networking_role = remote_rlbot_server network_address = 192.168.1.100 [Team Configuration] @@ -10,11 +10,15 @@ network_address = 192.168.1.100 # Number of bots/players which will be spawned. We support up to max 10. num_participants = 1 game_mode = Soccer -game_map = Mannfield -existing_match_behavior = Continue And Spawn +game_map = UtopiaColiseum_Snowy +existing_match_behavior = Restart [Mutator Configuration] # Visit https://github.com/RLBot/RLBot/wiki/Config-File-Documentation to see what you can put here. +Respawn Time = 1 Second +Boost Amount = Recharge (Fast) +Rumble = Spike Rush +Match Length = Unlimited [Participant Configuration] # Put the name of your bot config file here. Only num_participants config files will be read! diff --git a/src/bot.py b/src/bot.py index 98aa525..915de8d 100644 --- a/src/bot.py +++ b/src/bot.py @@ -1,6 +1,5 @@ import math -from quicktracer import trace from rlbot.agents.base_agent import BaseAgent, SimpleControllerState from rlbot.utils.structures.game_data_struct import GameTickPacket @@ -15,9 +14,6 @@ def get_output(self, packet: GameTickPacket) -> SimpleControllerState: car_location = Vec3(my_car.physics.location) ball_location = Vec3(packet.game_ball.physics.location) - # trace makes a pretty graph of whatever numeric variable you pass - trace(car_location.dist(ball_location)) - # Numbers taken from https://github.com/RLBot/RLBot/wiki/Useful-Game-Values enemy_goal_y_value = 5200 if my_car.team == 0 else -5200 enemy_goal_location = Vec3(0, enemy_goal_y_value, 0) pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy