From 00cdfbf4feeb14d90cc1845ac59d908a7b5c384f Mon Sep 17 00:00:00 2001 From: Tyler Date: Tue, 11 Jun 2019 19:37:06 -0700 Subject: [PATCH 01/14] Update README.md --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 05f8b47..e7c2910 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,6 @@ https://youtu.be/mPfYqKe_KRs 1. Make sure you've installed the Java 8 JDK or newer. Here's the [Java 8 JDK](https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html). 1. Make sure you've [set the JAVA_HOME environment variable](https://javatutorial.net/set-java-home-windows-10). 1. Download this repository -1. Open Rocket League 1. Double click on run-bot.bat and leave it running. It's supposed to stay open and it's OK if it says something like "75%". 1. Double click on run-gui.bat From 007f4c13898637289c50134bcca51056b18e6027 Mon Sep 17 00:00:00 2001 From: Tyler Arehart Date: Tue, 11 Jun 2019 09:42:54 -0700 Subject: [PATCH 02/14] Switching to socket-based python interop, and adding a nice icon. --- build.gradle | 22 ++++--- src/main/java/rlbotexample/JavaExample.java | 56 +++++++++++------- .../rlbotexample/SamplePythonInterface.java | 8 +-- .../java/rlbotexample/util/PortReader.java | 23 +++---- src/main/python/javaExample.py | 15 ++--- src/main/python/port.cfg | Bin 8 -> 0 bytes src/main/resources/icon.png | Bin 0 -> 18448 bytes 7 files changed, 65 insertions(+), 59 deletions(-) delete mode 100644 src/main/python/port.cfg create mode 100644 src/main/resources/icon.png diff --git a/build.gradle b/build.gradle index 7863d80..0124827 100644 --- a/build.gradle +++ b/build.gradle @@ -15,15 +15,7 @@ mainClassName = 'rlbotexample.JavaExample' // This directory will be created and the interface dll copied into it at runtime. // The end result is that the interface dll will be available for loading. def dllDirectory = 'build/dll' - -applicationDefaultJvmArgs = ["-Djna.library.path=" + dllDirectory, "-Duser.dir=MY_WORKING_DIR"] - -// https://www.mkyong.com/gradle/gradle-application-plugin-app_home-in-applicationdefaultjvmargs/ -startScripts { - doLast { - windowsScript.text = windowsScript.text.replace('MY_WORKING_DIR', "%~dp0.") - } -} +applicationDefaultJvmArgs = ["-Djna.library.path=" + dllDirectory] dependencies { // Fetch the framework jar file @@ -86,7 +78,13 @@ distZip { exclude '__pycache__' } } - into (applicationName + '/bin') { - from fileTree('port.cfg') +} + +// This is the same as distZip, but not zipped. Handy for testing your tournament submission more rapidly. +installDist { + into ('../python') { + from fileTree('src/main/python') { + exclude '__pycache__' + } } -} \ No newline at end of file +} diff --git a/src/main/java/rlbotexample/JavaExample.java b/src/main/java/rlbotexample/JavaExample.java index 3b910ab..c188933 100644 --- a/src/main/java/rlbotexample/JavaExample.java +++ b/src/main/java/rlbotexample/JavaExample.java @@ -1,15 +1,15 @@ package rlbotexample; import rlbot.manager.BotManager; -import rlbot.pyinterop.PythonInterface; -import rlbot.pyinterop.PythonServer; import rlbotexample.util.PortReader; import javax.swing.*; import javax.swing.border.EmptyBorder; +import java.awt.*; import java.awt.event.ActionListener; -import java.util.OptionalInt; +import java.net.URL; import java.util.Set; +import java.util.stream.Collectors; /** * See JavaAgent.py for usage instructions. @@ -18,41 +18,57 @@ */ public class JavaExample { + private static final Integer DEFAULT_PORT = 17357; + public static void main(String[] args) { BotManager botManager = new BotManager(); - PythonInterface pythonInterface = new SamplePythonInterface(botManager); - Integer port = PortReader.readPortFromFile("port.cfg"); - PythonServer pythonServer = new PythonServer(pythonInterface, port); - pythonServer.start(); + Integer port = PortReader.readPortFromArgs(args).orElseGet(() -> { + System.out.println("Could not read port from args, using default!"); + return DEFAULT_PORT; + }); + + SamplePythonInterface pythonInterface = new SamplePythonInterface(port, botManager); + new Thread(pythonInterface::start).start(); JFrame frame = new JFrame("Java Bot"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPanel panel = new JPanel(); panel.setBorder(new EmptyBorder(10, 10, 10, 10)); - panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); - panel.add(new JLabel("Listening on port " + port)); - panel.add(new JLabel("I'm the thing controlling the Java bot, keep me open :)")); + BorderLayout borderLayout = new BorderLayout(); + panel.setLayout(borderLayout); + JPanel dataPanel = new JPanel(); + dataPanel.setLayout(new BoxLayout(dataPanel, BoxLayout.Y_AXIS)); + dataPanel.setBorder(new EmptyBorder(0, 10, 0, 0)); + dataPanel.add(new JLabel("Listening on port " + port), BorderLayout.CENTER); + dataPanel.add(new JLabel("I'm the thing controlling the Java bot, keep me open :)"), BorderLayout.CENTER); JLabel botsRunning = new JLabel("Bots running: "); - panel.add(botsRunning); + dataPanel.add(botsRunning, BorderLayout.CENTER); + panel.add(dataPanel, BorderLayout.CENTER); frame.add(panel); + URL url = JavaExample.class.getClassLoader().getResource("icon.png"); + Image image = Toolkit.getDefaultToolkit().createImage(url); + panel.add(new JLabel(new ImageIcon(image)), BorderLayout.WEST); + frame.setIconImage(image); + frame.pack(); frame.setVisible(true); ActionListener myListener = e -> { Set runningBotIndices = botManager.getRunningBotIndices(); - OptionalInt maxIndex = runningBotIndices.stream().mapToInt(k -> k).max(); - String botsStr = "None"; - if (maxIndex.isPresent()) { - StringBuilder botsStrBuilder = new StringBuilder(); - for (int i = 0; i <= maxIndex.getAsInt(); i++) { - botsStrBuilder.append(runningBotIndices.contains(i) ? "☑ " : "☐ "); - } - botsStr = botsStrBuilder.toString(); + + String botsStr; + if (runningBotIndices.isEmpty()) { + botsStr = "None"; + } else { + botsStr = runningBotIndices.stream() + .sorted() + .map(i -> "#" + i) + .collect(Collectors.joining(", ")); } - botsRunning.setText("Bots running: " + botsStr); + botsRunning.setText("Bots indices running: " + botsStr); }; new Timer(1000, myListener).start(); diff --git a/src/main/java/rlbotexample/SamplePythonInterface.java b/src/main/java/rlbotexample/SamplePythonInterface.java index e6812ca..829aa93 100644 --- a/src/main/java/rlbotexample/SamplePythonInterface.java +++ b/src/main/java/rlbotexample/SamplePythonInterface.java @@ -2,12 +2,12 @@ import rlbot.Bot; import rlbot.manager.BotManager; -import rlbot.pyinterop.DefaultPythonInterface; +import rlbot.pyinterop.SocketServer; -public class SamplePythonInterface extends DefaultPythonInterface { +public class SamplePythonInterface extends SocketServer { - public SamplePythonInterface(BotManager botManager) { - super(botManager); + public SamplePythonInterface(int port, BotManager botManager) { + super(port, botManager); } protected Bot initBot(int index, String botType, int team) { diff --git a/src/main/java/rlbotexample/util/PortReader.java b/src/main/java/rlbotexample/util/PortReader.java index 892b662..3664bdd 100644 --- a/src/main/java/rlbotexample/util/PortReader.java +++ b/src/main/java/rlbotexample/util/PortReader.java @@ -1,28 +1,23 @@ package rlbotexample.util; -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; import java.util.Optional; -import java.util.stream.Stream; /** - * Utility for reading a network port out of a config file. We're expecting a file that has only one line - * that's just a number. + * Utility for reading a network port out of a command line arguments. * * This class is here for your convenience, it is NOT part of the framework. You can add to it as much * as you want, or delete it. */ public class PortReader { - public static Integer readPortFromFile(String s) { - Path path = Paths.get(s); - try (Stream lines = Files.lines(path)) { - Optional firstLine = lines.findFirst(); - return firstLine.map(Integer::parseInt).orElseThrow(() -> new RuntimeException("Port config file was empty!")); - } catch (final IOException e) { - throw new RuntimeException("Failed to read port file! Tried to find it at " + path.toAbsolutePath().toString()); + public static Optional readPortFromArgs(String[] args) { + if (args.length == 0) { + return Optional.empty(); + } + try { + return Optional.of(Integer.parseInt(args[0])); + } catch (NumberFormatException e) { + return Optional.empty(); } } } diff --git a/src/main/python/javaExample.py b/src/main/python/javaExample.py index dad0097..faf3765 100644 --- a/src/main/python/javaExample.py +++ b/src/main/python/javaExample.py @@ -1,18 +1,15 @@ -import os - from rlbot.agents.base_agent import BOT_CONFIG_AGENT_HEADER -from rlbot.agents.base_java_agent import BaseJavaAgent +from rlbot.agents.executable_with_socket_agent import ExecutableWithSocketAgent from rlbot.parsing.custom_config import ConfigHeader, ConfigObject -class JavaExample(BaseJavaAgent): - def get_port_file_path(self): - # Look for a port.cfg file in the same directory as THIS python file. - return os.path.realpath(os.path.join(os.getcwd(), os.path.dirname(__file__), 'port.cfg')) +class JavaExample(ExecutableWithSocketAgent): + def get_port(self) -> int: + return 17357 def load_config(self, config_header: ConfigHeader): - self.java_executable_path = config_header.getpath('java_executable_path') - self.logger.info("Java executable is configured as {}".format(self.java_executable_path)) + self.executable_path = config_header.getpath('java_executable_path') + self.logger.info("Java executable is configured as {}".format(self.executable_path)) @staticmethod def create_agent_configurations(config: ConfigObject): diff --git a/src/main/python/port.cfg b/src/main/python/port.cfg deleted file mode 100644 index 1256cfb1817cf7effe298709bcf1c94f4cf727fd..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 8 PcmXpsH#Rlr zaB^>EX>4U6ba`-PAZ2)IW&i+q+O3>vmgP8(tp95jwFGe{m%~Zt^bUIY?=w)>-6Jw1 zyQ}(DR7SYpLE-=y%m7f={_p>Ku7CaOU(Wdyub4{BE$5s6#TJ|I{7~=nzw@uVqy26F zi|$sv*BhRf0{@2dYu@kYJFlnjFO>HSZv6WCRpxu0`d;XL<8#5FJ9~b3KUd!i z1%F<5@9$T8zt`iB>Ae4iVwd>(@bACJ!eXq%i@{%h2N!Ps))#$X1fhk_znQ;XaD3=~ zUy1x3x!B*X-Sze3Z;SW!({F2c_xJVi>rz~Iem{_ZTch`Nm;Qe3Y=wS~$bH}Wmp9g9 zhVcErA8YqKt3J;@v+FUlQu%r(^_hzO#0LjU8SHDBKZXAiKNtJc_*0qUWYHJ9IruX# z*PLgy9~a$n-92vGztc^I82$Ezf4!eR*lRTu-~6;qiTdLnU)YRwh00z{b}jI-{~C+4 z`!>7Zbd@_V$0xnxVvcY8<6hIUSW^C>pOJ@1+( zTVMNg{ji(+$HoSBFxfI!CfM(BE-{k(wyj|M9Qa(is>UD3vQ=EO)Cx2cBTG)t$(-gJ_cVV+) zOxRC}6&va)fJZ5%oJy*xrJh5MIpv&77Dn|FN-U}5Qc5kY^crfcspeX0t*!RvTL8jR z%dK3kw$^&*rkzW7zTNpm@57HU;z%QpGU{lfPt0e=nP#44*4buXeuahm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vu` zABpqjuij37rmxU6Vc9lszWq9BJ97wquP-X)cJW|-j7J|_AmO-JOFqxkI|}W&dw{w5 z4$!|F14c37LEz^AMWG_@``-ViZbDtb2QUqTl5p93_VN>n0akwu^sc~wWixoe6{Eq& zfb)(O{KpbNZhSG9Nv1el%+fF1NolyGuvbSC@vOmCg5+KUuJEP7ZU*14#C$bb8h(y`Gb34Q7SV1`=s!%Te$z!*O}4LnNGI!pV7e`Oa_L$$z~5j0%CrTqB& zKj!wUmL3G3vymc#@)!t;-wh3smZS5)5g}1riFe6oss7w`1sMYW{o{f^ZVVX3gdp%V za1LajK6&D)C%EOFn>nOXf#9TF#1VcRF6QE3_=pt zcwBBC$9af|3H%@63;AQ)wr^wUHR=WN@kTv$*dA7o>nZu>X7_; zMzyTG;B49U$KSh_WsN>1DI#Czzv>VXzlhu`BAL;s_O$GA?)%AoQam*xH{N`sta;^S zNhgzX*my%kX7G#7;Pf*xt>$&P5#k_h@37WE9A&ymx$aVBL1FJ z>%Bdv)@%MzhltD&k^4ntzli) Date: Sun, 30 Jun 2019 13:01:50 -0700 Subject: [PATCH 03/14] Updating ControlsOutput to include useItem (for rumble). --- .../java/rlbotexample/output/ControlsOutput.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/main/java/rlbotexample/output/ControlsOutput.java b/src/main/java/rlbotexample/output/ControlsOutput.java index b544024..ace5d65 100644 --- a/src/main/java/rlbotexample/output/ControlsOutput.java +++ b/src/main/java/rlbotexample/output/ControlsOutput.java @@ -28,6 +28,7 @@ public class ControlsOutput implements ControllerState { private boolean jumpDepressed; private boolean boostDepressed; private boolean slideDepressed; + private boolean useItemDepressed; public ControlsOutput() { } @@ -72,6 +73,11 @@ public ControlsOutput withSlide(boolean slideDepressed) { return this; } + public ControlsOutput withUseItem(boolean useItemDepressed) { + this.useItemDepressed = useItemDepressed; + return this; + } + public ControlsOutput withJump() { this.jumpDepressed = true; return this; @@ -87,6 +93,11 @@ public ControlsOutput withSlide() { return this; } + public ControlsOutput withUseItem() { + this.useItemDepressed = true; + return this; + } + private float clamp(float value) { return Math.max(-1, Math.min(1, value)); } @@ -130,4 +141,9 @@ public boolean holdBoost() { public boolean holdHandbrake() { return slideDepressed; } + + @Override + public boolean holdUseItem() { + return useItemDepressed; + } } From 82f97803f86746b027adca2b4fbb6879ec7f9c3e Mon Sep 17 00:00:00 2001 From: NicEastvillage Date: Thu, 4 Jul 2019 12:06:15 +0200 Subject: [PATCH 04/14] Fixed comment --- src/main/java/rlbotexample/dropshot/DropshotTile.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/rlbotexample/dropshot/DropshotTile.java b/src/main/java/rlbotexample/dropshot/DropshotTile.java index 06c639a..a81f553 100644 --- a/src/main/java/rlbotexample/dropshot/DropshotTile.java +++ b/src/main/java/rlbotexample/dropshot/DropshotTile.java @@ -11,7 +11,7 @@ */ public class DropshotTile { - public static final double TILE_SIZE = 443.405; // side length and length from center to side + public static final double TILE_SIZE = 443.405; // side length and length from center to corner public static final double TILE_WIDTH = 768; // length from side to opposite side public static final double TILE_HEIGHT = 886.81; // length from corner to opposite corner From 6776eeccd06cb922401d3054421145032b4cb59e Mon Sep 17 00:00:00 2001 From: Tyler Arehart Date: Sat, 24 Aug 2019 09:13:23 -0700 Subject: [PATCH 05/14] Adding a ball prediction helper, and removing dropshot code since we lost support. --- src/main/java/rlbotexample/SampleBot.java | 23 ++-- .../rlbotexample/dropshot/DropshotTile.java | 42 -------- .../dropshot/DropshotTileManager.java | 100 ------------------ .../dropshot/DropshotTileState.java | 8 -- src/main/java/rlbotexample/dropshot/Hex.java | 61 ----------- .../prediction/BallPredictionHelper.java | 30 ++++++ 6 files changed, 39 insertions(+), 225 deletions(-) delete mode 100644 src/main/java/rlbotexample/dropshot/DropshotTile.java delete mode 100644 src/main/java/rlbotexample/dropshot/DropshotTileManager.java delete mode 100644 src/main/java/rlbotexample/dropshot/DropshotTileState.java delete mode 100644 src/main/java/rlbotexample/dropshot/Hex.java create mode 100644 src/main/java/rlbotexample/prediction/BallPredictionHelper.java diff --git a/src/main/java/rlbotexample/SampleBot.java b/src/main/java/rlbotexample/SampleBot.java index b4a116f..1639980 100644 --- a/src/main/java/rlbotexample/SampleBot.java +++ b/src/main/java/rlbotexample/SampleBot.java @@ -3,17 +3,17 @@ import rlbot.Bot; import rlbot.ControllerState; import rlbot.cppinterop.RLBotDll; +import rlbot.cppinterop.RLBotInterfaceException; +import rlbot.flat.BallPrediction; import rlbot.flat.GameTickPacket; import rlbot.flat.QuickChatSelection; import rlbot.manager.BotLoopRenderer; import rlbot.render.Renderer; import rlbotexample.boost.BoostManager; -import rlbotexample.dropshot.DropshotTile; -import rlbotexample.dropshot.DropshotTileManager; -import rlbotexample.dropshot.DropshotTileState; import rlbotexample.input.CarData; import rlbotexample.input.DataPacket; import rlbotexample.output.ControlsOutput; +import rlbotexample.prediction.BallPredictionHelper; import rlbotexample.vector.Vector2; import java.awt.*; @@ -75,17 +75,13 @@ private void drawDebugLines(DataPacket input, CarData myCar, boolean goLeft) { renderer.drawString3d(goLeft ? "left" : "right", Color.WHITE, myCar.position, 2, 2); - for (DropshotTile tile: DropshotTileManager.getTiles()) { - if (tile.getState() == DropshotTileState.DAMAGED) { - renderer.drawCenteredRectangle3d(Color.YELLOW, tile.getLocation(), 4, 4, true); - } else if (tile.getState() == DropshotTileState.DESTROYED) { - renderer.drawCenteredRectangle3d(Color.RED, tile.getLocation(), 4, 4, true); - } + try { + // Draw 3 seconds of ball prediction + BallPrediction ballPrediction = RLBotDll.getBallPrediction(); + BallPredictionHelper.drawTillMoment(ballPrediction, myCar.elapsedSeconds + 3, Color.CYAN, renderer); + } catch (RLBotInterfaceException e) { + e.printStackTrace(); } - - // Draw a rectangle on the tile that the car is on - DropshotTile tile = DropshotTileManager.pointToTile(myCar.position.flatten()); - if (tile != null) renderer.drawCenteredRectangle3d(Color.green, tile.getLocation(), 8, 8, false); } @@ -108,7 +104,6 @@ public ControllerState processInput(GameTickPacket packet) { // Update the boost manager and tile manager with the latest data BoostManager.loadGameTickPacket(packet); - DropshotTileManager.loadGameTickPacket(packet); // Translate the raw packet data (which is in an unpleasant format) into our custom DataPacket class. // The DataPacket might not include everything from GameTickPacket, so improve it if you need to! diff --git a/src/main/java/rlbotexample/dropshot/DropshotTile.java b/src/main/java/rlbotexample/dropshot/DropshotTile.java deleted file mode 100644 index a81f553..0000000 --- a/src/main/java/rlbotexample/dropshot/DropshotTile.java +++ /dev/null @@ -1,42 +0,0 @@ -package rlbotexample.dropshot; - - -import rlbotexample.vector.Vector3; - -/** - * Representation of one of the floor tiles in dropshot mode. - * - * This class is here for your convenience, it is NOT part of the framework. You can change it as much - * as you want, or delete it. - */ -public class DropshotTile { - - public static final double TILE_SIZE = 443.405; // side length and length from center to corner - public static final double TILE_WIDTH = 768; // length from side to opposite side - public static final double TILE_HEIGHT = 886.81; // length from corner to opposite corner - - private final Vector3 location; - private final int team; - private DropshotTileState state; - - public DropshotTile(Vector3 location) { - this.location = location; - this.team = location.y < 0 ? 0 : 1; - } - - public void setState(DropshotTileState state) { - this.state = state; - } - - public Vector3 getLocation() { - return location; - } - - public DropshotTileState getState() { - return state; - } - - public int getTeam() { - return team; - } -} diff --git a/src/main/java/rlbotexample/dropshot/DropshotTileManager.java b/src/main/java/rlbotexample/dropshot/DropshotTileManager.java deleted file mode 100644 index fcd82dd..0000000 --- a/src/main/java/rlbotexample/dropshot/DropshotTileManager.java +++ /dev/null @@ -1,100 +0,0 @@ -package rlbotexample.dropshot; - -import rlbot.cppinterop.RLBotDll; -import rlbot.flat.FieldInfo; -import rlbot.flat.GameTickPacket; -import rlbotexample.vector.Vector2; -import rlbotexample.vector.Vector3; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; - -import static rlbotexample.dropshot.DropshotTile.TILE_HEIGHT; -import static rlbotexample.dropshot.DropshotTile.TILE_WIDTH; - -/** - * Information about where dropshot tiles are located in the arena and what state they have. Can also convert a - * vector2 point to a tile, which is useful for checking the state of the tile where the ball lands. - * - * This class is here for your convenience, it is NOT part of the framework. You can change it as much - * as you want, or delete it. - */ -public class DropshotTileManager { - - private static final ArrayList tiles = new ArrayList<>(); - private static final HashMap blueTileMap = new HashMap<>(); - private static final HashMap orangeTileMap = new HashMap<>(); - - public static List getTiles() { - return tiles; - } - - private static void loadFieldInfo(FieldInfo fieldInfo) { - - synchronized (tiles) { - - tiles.clear(); - - for (int i = 0; i < fieldInfo.goalsLength(); i++) { - rlbot.flat.GoalInfo goalInfo = fieldInfo.goals(i); - Vector3 location = new Vector3(goalInfo.location()); - DropshotTile tile = new DropshotTile(location); - tiles.add(new DropshotTile(location)); - - Hex hex = pointToHex(location.flatten()); - if (location.y < 0) { - blueTileMap.put(hex, tile); - } else { - orangeTileMap.put(hex, tile); - } - } - } - } - - public static void loadGameTickPacket(GameTickPacket packet) { - - if (packet.tileInformationLength() > tiles.size()) { - try { - loadFieldInfo(RLBotDll.getFieldInfo()); - } catch (IOException e) { - e.printStackTrace(); - return; - } - } - - for (int i = 0; i < packet.tileInformationLength(); i++) { - rlbot.flat.DropshotTile tile = packet.tileInformation(i); - DropshotTile existingTile = tiles.get(i); - existingTile.setState(DropshotTileState.values()[tile.tileState()]); - } - } - - /** - * Returns the tile under the point, or null if none is. - */ - public static DropshotTile pointToTile(Vector2 point) { - Hex hex = pointToHex(point); - if (point.y < 0) return blueTileMap.get(hex); - else return orangeTileMap.get(hex); - } - - /** - * Converts a point to a hex. - */ - private static Hex pointToHex(Vector2 point) { - - // Apply offset - if (point.y < 0) { - point = point.plus(new Vector2(0, 128)); - } else { - point = point.plus(new Vector2(0, -128)); - } - - // Calculate q and r component - double q = point.x / TILE_WIDTH - point.y * 2 / (3 * TILE_HEIGHT); - double r = point.y * 4 / (3 * TILE_HEIGHT); - return Hex.fromRounding(q, r); - } -} diff --git a/src/main/java/rlbotexample/dropshot/DropshotTileState.java b/src/main/java/rlbotexample/dropshot/DropshotTileState.java deleted file mode 100644 index b2dba3f..0000000 --- a/src/main/java/rlbotexample/dropshot/DropshotTileState.java +++ /dev/null @@ -1,8 +0,0 @@ -package rlbotexample.dropshot; - -public enum DropshotTileState { - UNKNOWN, - FRESH, - DAMAGED, - DESTROYED -} diff --git a/src/main/java/rlbotexample/dropshot/Hex.java b/src/main/java/rlbotexample/dropshot/Hex.java deleted file mode 100644 index eef320e..0000000 --- a/src/main/java/rlbotexample/dropshot/Hex.java +++ /dev/null @@ -1,61 +0,0 @@ -package rlbotexample.dropshot; - -import java.util.Objects; - -/** - * This class is used to convert a 2d point to a hex grid in the DropshotTileManager. Look here for more information: - * https://www.redblobgames.com/grids/hexagons/ - * - * This class is here for your convenience, it is NOT part of the framework. You can add to it as much - * as you want, or delete it. - */ -public class Hex { - - // For a hex the following must always be true: q + r + s == 0 - public final int q, r, s; - - public Hex(int q, int r) { - this.q = q; - this.r = r; - this.s = -q - r; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - Hex that = (Hex) o; - return q == that.q && - r == that.r; - } - - @Override - public int hashCode() { - return Objects.hash(q, r); - } - - /** - * Construct a Hex from rounding two floating point q and r coordinates. - */ - public static Hex fromRounding(double fq, double fr) { - double fs = -fq - fr; - - int rx = (int)Math.round(fq); - int ry = (int)Math.round(fr); - int rz = (int)Math.round(fs); - - // Find how much each component was rounded - double x_diff = Math.abs(rx - fq); - double y_diff = Math.abs(ry - fr); - double z_diff = Math.abs(rz - fs); - - // We reset the component with the largest change back to what the constraint rx + ry + rz = 0 requires - if (x_diff > y_diff && x_diff > z_diff) { - rx = -ry - rz; - } else if (y_diff > z_diff) { - ry = -rx - rz; - } - - return new Hex(rx, ry); - } -} diff --git a/src/main/java/rlbotexample/prediction/BallPredictionHelper.java b/src/main/java/rlbotexample/prediction/BallPredictionHelper.java new file mode 100644 index 0000000..77b56c7 --- /dev/null +++ b/src/main/java/rlbotexample/prediction/BallPredictionHelper.java @@ -0,0 +1,30 @@ +package rlbotexample.prediction; + +import rlbot.flat.BallPrediction; +import rlbot.flat.PredictionSlice; +import rlbot.render.Renderer; +import rlbotexample.vector.Vector3; + +import java.awt.*; + +/** + * This class can help you get started with ball prediction. Feel free to change it as much as you want, + * this is part of your bot, not part of the framework! + */ +public class BallPredictionHelper { + + public static void drawTillMoment(BallPrediction ballPrediction, float gameSeconds, Color color, Renderer renderer) { + Vector3 previousLocation = null; + for (int i = 0; i < ballPrediction.slicesLength(); i += 4) { + PredictionSlice slice = ballPrediction.slices(i); + if (slice.gameSeconds() > gameSeconds) { + break; + } + Vector3 location = new Vector3(slice.physics().location()); + if (previousLocation != null) { + renderer.drawLine3d(color, previousLocation, location); + } + previousLocation = location; + } + } +} From 98babb46a5534433e512b5f6f07f934b43b58452 Mon Sep 17 00:00:00 2001 From: Tyler Arehart Date: Tue, 27 Aug 2019 10:26:15 -0700 Subject: [PATCH 06/14] Getting rid of unused port.cfg file. --- port.cfg | Bin 8 -> 0 bytes src/main/python/README_Tournament.md | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) delete mode 100644 port.cfg diff --git a/port.cfg b/port.cfg deleted file mode 100644 index 1256cfb1817cf7effe298709bcf1c94f4cf727fd..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 8 PcmXpsH#Rlr Date: Sun, 6 Oct 2019 22:39:37 +0100 Subject: [PATCH 07/14] Add a BallTouch class (#16) --- src/main/java/rlbotexample/SampleBot.java | 8 ++++- .../java/rlbotexample/input/DataPacket.java | 2 ++ .../input/{ => ball}/BallData.java | 6 +++- .../rlbotexample/input/ball/BallTouch.java | 29 +++++++++++++++++++ .../rlbotexample/input/{ => car}/CarData.java | 2 +- .../input/{ => car}/CarOrientation.java | 2 +- 6 files changed, 45 insertions(+), 4 deletions(-) rename src/main/java/rlbotexample/input/{ => ball}/BallData.java (70%) create mode 100644 src/main/java/rlbotexample/input/ball/BallTouch.java rename src/main/java/rlbotexample/input/{ => car}/CarData.java (98%) rename src/main/java/rlbotexample/input/{ => car}/CarOrientation.java (98%) diff --git a/src/main/java/rlbotexample/SampleBot.java b/src/main/java/rlbotexample/SampleBot.java index 1639980..80c5e3d 100644 --- a/src/main/java/rlbotexample/SampleBot.java +++ b/src/main/java/rlbotexample/SampleBot.java @@ -10,8 +10,8 @@ import rlbot.manager.BotLoopRenderer; import rlbot.render.Renderer; import rlbotexample.boost.BoostManager; -import rlbotexample.input.CarData; import rlbotexample.input.DataPacket; +import rlbotexample.input.car.CarData; import rlbotexample.output.ControlsOutput; import rlbotexample.prediction.BallPredictionHelper; import rlbotexample.vector.Vector2; @@ -75,6 +75,12 @@ private void drawDebugLines(DataPacket input, CarData myCar, boolean goLeft) { renderer.drawString3d(goLeft ? "left" : "right", Color.WHITE, myCar.position, 2, 2); + if(input.ball.hasBeenTouched) { + float lastTouchTime = myCar.elapsedSeconds - input.ball.latestTouch.gameSeconds; + Color touchColor = input.ball.latestTouch.team == 0 ? Color.BLUE : Color.ORANGE; + renderer.drawString3d((int)lastTouchTime + "s", touchColor, input.ball.position, 2, 2); + } + try { // Draw 3 seconds of ball prediction BallPrediction ballPrediction = RLBotDll.getBallPrediction(); diff --git a/src/main/java/rlbotexample/input/DataPacket.java b/src/main/java/rlbotexample/input/DataPacket.java index 7001897..a61b69c 100644 --- a/src/main/java/rlbotexample/input/DataPacket.java +++ b/src/main/java/rlbotexample/input/DataPacket.java @@ -1,6 +1,8 @@ package rlbotexample.input; import rlbot.flat.GameTickPacket; +import rlbotexample.input.ball.BallData; +import rlbotexample.input.car.CarData; import java.util.ArrayList; import java.util.List; diff --git a/src/main/java/rlbotexample/input/BallData.java b/src/main/java/rlbotexample/input/ball/BallData.java similarity index 70% rename from src/main/java/rlbotexample/input/BallData.java rename to src/main/java/rlbotexample/input/ball/BallData.java index c7f042f..8dffab4 100644 --- a/src/main/java/rlbotexample/input/BallData.java +++ b/src/main/java/rlbotexample/input/ball/BallData.java @@ -1,4 +1,4 @@ -package rlbotexample.input; +package rlbotexample.input.ball; import rlbot.flat.BallInfo; @@ -14,10 +14,14 @@ public class BallData { public final Vector3 position; public final Vector3 velocity; public final Vector3 spin; + public final BallTouch latestTouch; + public final boolean hasBeenTouched; public BallData(final BallInfo ball) { this.position = new Vector3(ball.physics().location()); this.velocity = new Vector3(ball.physics().velocity()); this.spin = new Vector3(ball.physics().angularVelocity()); + this.hasBeenTouched = ball.latestTouch() != null; + this.latestTouch = this.hasBeenTouched ? new BallTouch(ball.latestTouch()) : null; } } diff --git a/src/main/java/rlbotexample/input/ball/BallTouch.java b/src/main/java/rlbotexample/input/ball/BallTouch.java new file mode 100644 index 0000000..d0af1bb --- /dev/null +++ b/src/main/java/rlbotexample/input/ball/BallTouch.java @@ -0,0 +1,29 @@ +package rlbotexample.input.ball; + + +import rlbot.flat.Touch; +import rlbotexample.vector.Vector3; + +/** + * Basic information about the ball's latest touch. + * + * This class is here for your convenience, it is NOT part of the framework. You can change it as much + * as you want, or delete it. + */ +public class BallTouch { + public final Vector3 position; + public final Vector3 normal; + public final String playerName; + public final float gameSeconds; + public final int playerIndex; + public final int team; + + public BallTouch(final Touch touch) { + this.position = new Vector3(touch.location()); + this.normal = new Vector3(touch.normal()); + this.playerName = touch.playerName(); + this.gameSeconds = touch.gameSeconds(); + this.playerIndex = touch.playerIndex(); + this.team = touch.team(); + } +} diff --git a/src/main/java/rlbotexample/input/CarData.java b/src/main/java/rlbotexample/input/car/CarData.java similarity index 98% rename from src/main/java/rlbotexample/input/CarData.java rename to src/main/java/rlbotexample/input/car/CarData.java index 87fbfa9..1023e73 100644 --- a/src/main/java/rlbotexample/input/CarData.java +++ b/src/main/java/rlbotexample/input/car/CarData.java @@ -1,4 +1,4 @@ -package rlbotexample.input; +package rlbotexample.input.car; import rlbotexample.vector.Vector3; diff --git a/src/main/java/rlbotexample/input/CarOrientation.java b/src/main/java/rlbotexample/input/car/CarOrientation.java similarity index 98% rename from src/main/java/rlbotexample/input/CarOrientation.java rename to src/main/java/rlbotexample/input/car/CarOrientation.java index 84a0fa3..68370ec 100644 --- a/src/main/java/rlbotexample/input/CarOrientation.java +++ b/src/main/java/rlbotexample/input/car/CarOrientation.java @@ -1,4 +1,4 @@ -package rlbotexample.input; +package rlbotexample.input.car; import rlbot.flat.PlayerInfo; From 23c698fb1a2ab4c7b0c43299dc939378bc6c30e7 Mon Sep 17 00:00:00 2001 From: Antoine Tran <31257370+Tran-Antoine@users.noreply.github.com> Date: Tue, 19 Nov 2019 21:27:35 +0100 Subject: [PATCH 08/14] Minor improvements (#17) Minor changes, such as: - Usage of primitives instead of wrappers - Generified type declarations + added missing @Override annotations - Added method displayWindow --- src/main/java/rlbotexample/JavaExample.java | 8 ++++++-- src/main/java/rlbotexample/SampleBot.java | 1 + src/main/java/rlbotexample/SamplePythonInterface.java | 1 + src/main/java/rlbotexample/boost/BoostManager.java | 11 ++++++----- src/main/java/rlbotexample/output/ControlsOutput.java | 2 +- src/main/java/rlbotexample/vector/Vector2.java | 5 +++++ src/main/java/rlbotexample/vector/Vector3.java | 5 +++++ 7 files changed, 25 insertions(+), 8 deletions(-) diff --git a/src/main/java/rlbotexample/JavaExample.java b/src/main/java/rlbotexample/JavaExample.java index c188933..d3d7230 100644 --- a/src/main/java/rlbotexample/JavaExample.java +++ b/src/main/java/rlbotexample/JavaExample.java @@ -18,12 +18,12 @@ */ public class JavaExample { - private static final Integer DEFAULT_PORT = 17357; + private static final int DEFAULT_PORT = 17357; public static void main(String[] args) { BotManager botManager = new BotManager(); - Integer port = PortReader.readPortFromArgs(args).orElseGet(() -> { + int port = PortReader.readPortFromArgs(args).orElseGet(() -> { System.out.println("Could not read port from args, using default!"); return DEFAULT_PORT; }); @@ -31,6 +31,10 @@ public static void main(String[] args) { SamplePythonInterface pythonInterface = new SamplePythonInterface(port, botManager); new Thread(pythonInterface::start).start(); + displayWindow(botManager, port); + } + + private static void displayWindow(BotManager botManager, int port) { JFrame frame = new JFrame("Java Bot"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); diff --git a/src/main/java/rlbotexample/SampleBot.java b/src/main/java/rlbotexample/SampleBot.java index 80c5e3d..0a82f17 100644 --- a/src/main/java/rlbotexample/SampleBot.java +++ b/src/main/java/rlbotexample/SampleBot.java @@ -121,6 +121,7 @@ public ControllerState processInput(GameTickPacket packet) { return controlsOutput; } + @Override public void retire() { System.out.println("Retiring sample bot " + playerIndex); } diff --git a/src/main/java/rlbotexample/SamplePythonInterface.java b/src/main/java/rlbotexample/SamplePythonInterface.java index 829aa93..aa679bc 100644 --- a/src/main/java/rlbotexample/SamplePythonInterface.java +++ b/src/main/java/rlbotexample/SamplePythonInterface.java @@ -10,6 +10,7 @@ public SamplePythonInterface(int port, BotManager botManager) { super(port, botManager); } + @Override protected Bot initBot(int index, String botType, int team) { return new SampleBot(index); } diff --git a/src/main/java/rlbotexample/boost/BoostManager.java b/src/main/java/rlbotexample/boost/BoostManager.java index a9fa1bf..b93d7a6 100644 --- a/src/main/java/rlbotexample/boost/BoostManager.java +++ b/src/main/java/rlbotexample/boost/BoostManager.java @@ -8,6 +8,7 @@ import java.io.IOException; import java.util.ArrayList; +import java.util.List; /** * Information about where boost pads are located on the field and what status they have. @@ -17,15 +18,15 @@ */ public class BoostManager { - private static final ArrayList orderedBoosts = new ArrayList<>(); - private static final ArrayList fullBoosts = new ArrayList<>(); - private static final ArrayList smallBoosts = new ArrayList<>(); + private static final List orderedBoosts = new ArrayList<>(); + private static final List fullBoosts = new ArrayList<>(); + private static final List smallBoosts = new ArrayList<>(); - public static ArrayList getFullBoosts() { + public static List getFullBoosts() { return fullBoosts; } - public static ArrayList getSmallBoosts() { + public static List getSmallBoosts() { return smallBoosts; } diff --git a/src/main/java/rlbotexample/output/ControlsOutput.java b/src/main/java/rlbotexample/output/ControlsOutput.java index ace5d65..9cdbd2b 100644 --- a/src/main/java/rlbotexample/output/ControlsOutput.java +++ b/src/main/java/rlbotexample/output/ControlsOutput.java @@ -146,4 +146,4 @@ public boolean holdHandbrake() { public boolean holdUseItem() { return useItemDepressed; } -} +} \ No newline at end of file diff --git a/src/main/java/rlbotexample/vector/Vector2.java b/src/main/java/rlbotexample/vector/Vector2.java index 2197505..dad1633 100644 --- a/src/main/java/rlbotexample/vector/Vector2.java +++ b/src/main/java/rlbotexample/vector/Vector2.java @@ -98,4 +98,9 @@ public double correctionAngle(Vector2 ideal) { public static double angle(Vector2 a, Vector2 b) { return Math.abs(a.correctionAngle(b)); } + + @Override + public String toString() { + return String.format("(%s, %s)", x, y); + } } diff --git a/src/main/java/rlbotexample/vector/Vector3.java b/src/main/java/rlbotexample/vector/Vector3.java index b359c52..506ab21 100644 --- a/src/main/java/rlbotexample/vector/Vector3.java +++ b/src/main/java/rlbotexample/vector/Vector3.java @@ -99,4 +99,9 @@ public Vector3 crossProduct(Vector3 v) { double tz = x * v.y - y * v.x; return new Vector3(tx, ty, tz); } + + @Override + public String toString() { + return String.format("(%s, %s, %s)", x, y, z); + } } From f12ed427db7f84122561f9041a10dfd788622333 Mon Sep 17 00:00:00 2001 From: Tyler Arehart Date: Sat, 30 Nov 2019 02:24:11 -0800 Subject: [PATCH 09/14] Updating run.py to avoid https://github.com/RLBot/RLBot/issues/462. --- run.py | 38 ++++++++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/run.py b/run.py index 89b5a0e..60af312 100644 --- a/run.py +++ b/run.py @@ -1,36 +1,46 @@ +import sys + # https://stackoverflow.com/a/51704613 try: from pip import main as pipmain except ImportError: from pip._internal import main as pipmain +# More pip changes breaking us. +main_fn = pipmain +if hasattr(pipmain, 'main'): + main_fn = pipmain.main + +DEFAULT_LOGGER = 'rlbot' -# https://stackoverflow.com/a/24773951 -def install_and_import(package): - import importlib +if __name__ == '__main__': try: - importlib.import_module(package) - except ImportError: - pipmain(['install', package]) - finally: - globals()[package] = importlib.import_module(package) + from rlbot.utils import public_utils, logging_utils + logger = logging_utils.get_logger(DEFAULT_LOGGER) + if not public_utils.have_internet(): + logger.log(logging_utils.logging_level, + 'Skipping upgrade check for now since it looks like you have no internet') + elif public_utils.is_safe_to_upgrade(): + main_fn(['install', '-r', 'requirements.txt', '--upgrade', '--upgrade-strategy=eager']) -if __name__ == '__main__': - install_and_import('rlbot') - from rlbot.utils import public_utils + # https://stackoverflow.com/a/44401013 + rlbots = [module for module in sys.modules if module.startswith('rlbot')] + for rlbot_module in rlbots: + sys.modules.pop(rlbot_module) - if public_utils.is_safe_to_upgrade(): - pipmain(['install', '-r', 'requirements.txt', '--upgrade', '--upgrade-strategy=eager']) + except ImportError: + main_fn(['install', '-r', 'requirements.txt', '--upgrade', '--upgrade-strategy=eager']) try: - import sys if len(sys.argv) > 1 and sys.argv[1] == 'gui': from rlbot.gui.qt_root import RLBotQTGui + RLBotQTGui.main() else: from rlbot import runner + runner.main() except Exception as e: print("Encountered exception: ", e) From c5a016a2e829eca6da9727c566d46e7ab7f2009c Mon Sep 17 00:00:00 2001 From: Viliam Vadocz Date: Mon, 20 Jan 2020 11:47:13 +0100 Subject: [PATCH 10/14] Updated outdated comment --- rlbot.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rlbot.cfg b/rlbot.cfg index 80411c4..930f607 100644 --- a/rlbot.cfg +++ b/rlbot.cfg @@ -5,7 +5,7 @@ # 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. +# Number of bots/players which will be spawned. We support up to max 64. num_participants = 2 game_mode = Soccer game_map = Mannfield From 3a47339772324f34bb01fb90992b57bfa8763c37 Mon Sep 17 00:00:00 2001 From: Tyler Arehart Date: Mon, 23 Mar 2020 20:02:47 -0700 Subject: [PATCH 11/14] Upgrading to RLBot Java framework 2.0 and cleaning some obsolete gradle tasks. --- build.gradle | 40 ++-------------------------------------- run-bot.bat | 6 ------ 2 files changed, 2 insertions(+), 44 deletions(-) diff --git a/build.gradle b/build.gradle index 0124827..8f55dc7 100644 --- a/build.gradle +++ b/build.gradle @@ -19,54 +19,18 @@ applicationDefaultJvmArgs = ["-Djna.library.path=" + dllDirectory] dependencies { // Fetch the framework jar file - compile 'org.rlbot.commons:framework:1.+' + compile 'org.rlbot.commons:framework:2.+' // This is makes it easy to find the dll when running in intellij, where JVM args don't get passed from gradle. runtime files(dllDirectory) } -task checkPipUpgradeSafety { - doLast { - new ByteArrayOutputStream().withStream { os -> - def exitValue = exec { - commandLine "python", "-c", "from rlbot.utils import public_utils; print(public_utils.is_safe_to_upgrade());" - standardOutput = os - ignoreExitValue = true - }.exitValue - - // If the exit value is nonzero, the command probably failed because rlbot is not installed at all. - ext.isSafe = exitValue != 0 || os.toString().trim() == "True" - } - } -} - - -// Uses pip (the python package manager) to install all the python packages needed for this bot, as defined -// in requirements.txt. -task pipInstallRequirements { - dependsOn 'checkPipUpgradeSafety' - - doLast { - if (checkPipUpgradeSafety.isSafe) { - exec { - commandLine "python", "-m", "pip", "install", "-r", "requirements.txt", "--upgrade" - } - } else { - println 'Skipping upgrade attempt because files are in use.' - } - } -} task createDllDirectory { mkdir dllDirectory } -// Installs or updates RLBot. Empty task for now. It still does stuff because it "dependsOn" tasks that do things. -task updateRLBot { - dependsOn 'pipInstallRequirements' - dependsOn 'createDllDirectory' -} -updateRLBot.dependsOn pipInstallRequirements +run.dependsOn createDllDirectory applicationDistribution.exclude(dllDirectory) diff --git a/run-bot.bat b/run-bot.bat index 4508712..fd7a00b 100644 --- a/run-bot.bat +++ b/run-bot.bat @@ -1,12 +1,6 @@ @rem Change the working directory to the location of this file so that relative paths will work cd /D "%~dp0" -@rem Make sure the environment variables are up-to-date. This is useful if the user installed python a moment ago. -call ./RefreshEnv.cmd - -@rem Install or update rlbot and related python packages. -call ./gradlew.bat --no-daemon updateRLBot - @rem Start running the bot. call ./gradlew.bat --no-daemon run From 9b4c363dff8bc0b130f82b914c76adbed7c56a3b Mon Sep 17 00:00:00 2001 From: Tyler Date: Sun, 17 May 2020 18:33:26 -0700 Subject: [PATCH 12/14] Setting enable_rendering and enable_state_setting to true --- rlbot.cfg | 3 +++ 1 file changed, 3 insertions(+) diff --git a/rlbot.cfg b/rlbot.cfg index 930f607..7944055 100644 --- a/rlbot.cfg +++ b/rlbot.cfg @@ -5,10 +5,13 @@ # Visit https://github.com/RLBot/RLBot/wiki/Config-File-Documentation to see what you can put here. [Match Configuration] +# Visit https://github.com/RLBot/RLBot/wiki/Config-File-Documentation to see what you can put here. # Number of bots/players which will be spawned. We support up to max 64. num_participants = 2 game_mode = Soccer game_map = Mannfield +enable_rendering = True +enable_state_setting = True [Mutator Configuration] # Visit https://github.com/RLBot/RLBot/wiki/Config-File-Documentation to see what you can put here. From cb4db9648293b028861dc10596bc376786d08010 Mon Sep 17 00:00:00 2001 From: Tyler Arehart Date: Sun, 12 Jul 2020 15:09:57 -0700 Subject: [PATCH 13/14] Removing references to legacy GUI. --- README.md | 12 +++++------- run-gui.bat | 11 ----------- run.py | 27 ++++++--------------------- 3 files changed, 11 insertions(+), 39 deletions(-) delete mode 100644 run-gui.bat diff --git a/README.md b/README.md index e7c2910..d354da3 100644 --- a/README.md +++ b/README.md @@ -3,23 +3,21 @@ An example bot implemented in Java ## Video Guide -https://youtu.be/mPfYqKe_KRs +https://youtu.be/mPfYqKe_KRs (slightly outdated because it uses the old GUI) ## Usage Instructions: -1. Make sure you've installed Python 3.6.5 or newer. Here's [Python 3.7 64 bit](https://www.python.org/ftp/python/3.7.0/python-3.7.0-amd64.exe). Some older versions like 3.6.0 will not work. During installation: - - Select "Add Python to PATH" - - Make sure pip is included in the installation 1. Make sure you've installed the Java 8 JDK or newer. Here's the [Java 8 JDK](https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html). 1. Make sure you've [set the JAVA_HOME environment variable](https://javatutorial.net/set-java-home-windows-10). 1. Download this repository 1. Double click on run-bot.bat and leave it running. It's supposed to stay open and it's OK if it says something like "75%". -1. Double click on run-gui.bat -1. Click the 'Run' button + - Alternatively you can launch the bot from inside an IDE +1. Get RLBotGUI (see https://youtu.be/lPkID_IH88U for instructions). +1. Use Add -> Load folder in RLBotGUI on the current directory. This bot should appear in the list. +1. In RLBotGUI, put the bot on a team and start the match. - Bot behavior is controlled by `src/main/java/rlbotexample/SampleBot.java` -- Bot appearance is controlled by `src/main/python/javaExampleAppearance.cfg` See the [wiki](https://github.com/RLBot/RLBotJavaExample/wiki) for tips to improve your programming experience. diff --git a/run-gui.bat b/run-gui.bat deleted file mode 100644 index a1c00d9..0000000 --- a/run-gui.bat +++ /dev/null @@ -1,11 +0,0 @@ -@echo off - -@rem Change the working directory to the location of this file so that relative paths will work -cd /D "%~dp0" - -@rem Make sure the environment variables are up-to-date. This is useful if the user installed python a moment ago. -call ./RefreshEnv.cmd - -python run.py gui - -pause diff --git a/run.py b/run.py index 60af312..23ea98a 100644 --- a/run.py +++ b/run.py @@ -1,16 +1,6 @@ +import subprocess import sys -# https://stackoverflow.com/a/51704613 -try: - from pip import main as pipmain -except ImportError: - from pip._internal import main as pipmain - -# More pip changes breaking us. -main_fn = pipmain -if hasattr(pipmain, 'main'): - main_fn = pipmain.main - DEFAULT_LOGGER = 'rlbot' if __name__ == '__main__': @@ -23,7 +13,8 @@ logger.log(logging_utils.logging_level, 'Skipping upgrade check for now since it looks like you have no internet') elif public_utils.is_safe_to_upgrade(): - main_fn(['install', '-r', 'requirements.txt', '--upgrade', '--upgrade-strategy=eager']) + subprocess.call([sys.executable, "-m", "pip", "install", '-r', 'requirements.txt']) + subprocess.call([sys.executable, "-m", "pip", "install", 'rlbot', '--upgrade']) # https://stackoverflow.com/a/44401013 rlbots = [module for module in sys.modules if module.startswith('rlbot')] @@ -31,17 +22,11 @@ sys.modules.pop(rlbot_module) except ImportError: - main_fn(['install', '-r', 'requirements.txt', '--upgrade', '--upgrade-strategy=eager']) + subprocess.call([sys.executable, "-m", "pip", "install", '-r', 'requirements.txt', '--upgrade', '--upgrade-strategy=eager']) try: - if len(sys.argv) > 1 and sys.argv[1] == 'gui': - from rlbot.gui.qt_root import RLBotQTGui - - RLBotQTGui.main() - else: - from rlbot import runner - - runner.main() + from rlbot import runner + runner.main() except Exception as e: print("Encountered exception: ", e) print("Press enter to close.") From ffed34b232f5349fb81dd05c66fd63839ce8f5cd Mon Sep 17 00:00:00 2001 From: Tyler Arehart Date: Sun, 17 Oct 2021 17:45:14 -0700 Subject: [PATCH 14/14] Switching from jcenter to mavenCentral. --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 8f55dc7..e4bda5e 100644 --- a/build.gradle +++ b/build.gradle @@ -7,7 +7,7 @@ apply plugin: 'application' sourceCompatibility = 1.8 repositories { - jcenter() + mavenCentral() } mainClassName = 'rlbotexample.JavaExample'