Skip to content

Commit 06b91de

Browse files
committed
Updating to use the RLBot v4 branch as a dependency. Simpler setup.
1 parent 15e192d commit 06b91de

File tree

8 files changed

+56
-22
lines changed

8 files changed

+56
-22
lines changed

README.md

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,12 @@ An example bot implemented in Java
33

44
## Usage Instructions:
55

6-
These instructions should get dramatically simpler once we get our packages in jcenter.
7-
For now, this is what you need to do:
6+
1. Make sure you've installed [Python 3.6 64 bit](https://www.python.org/ftp/python/3.6.5/python-3.6.5-amd64.exe). During installation:
7+
- Select "Add Python to PATH"
8+
- Don't opt out of pip
9+
2. Open Rocket League
10+
3. Double click on run-bot.bat
11+
4. Double click on run-framework.bat
812

9-
1. Setup the RLBot framework - https://github.com/RLBot/RLBot (v4 branch for now)
10-
2. Create a new folder in the framework at /agents/protoBotJava.
11-
3. Copy the contents of the src/main/python folder the protoBotJava folder.
12-
4. Copy src/main/resources/port.cfg into the protoBotJava folder.
13-
5. In the framework directory, find rlbot.cfg and modify one of the lines to point to ./agents/protoBotJava/protoBotJava.cfg
14-
6. On the command line in this directory, execute `gradlew.bat run`
15-
7. On a different command line, in the framework directory, execute `python runner.py`
13+
- Bot behavior is controlled by `src/main/java/SampleBot.java`
14+
- Bot appearance is controlled by `src/main/python/protoBotJavaAppearance.cfg`

build.gradle

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
group 'RLBot'
2-
version '0.0.1'
1+
// This file controls gradle, which we are using to install and update the RLBot framework used by this example bot,
2+
// and also compile and run the java code used by this bot.
33

44
apply plugin: 'java'
55
apply plugin: 'application'
@@ -14,19 +14,39 @@ repositories {
1414
mainClassName = 'rlbot.JavaExample'
1515

1616
dependencies {
17-
compile 'com.github.tarehart:RLBot:gradle-build-SNAPSHOT'
18-
compile 'com.github.tarehart:RLBot:gradle-build-SNAPSHOT:python@zip' // Fetch the python zip
19-
runtime files('build/framework/RLBotFramework/dll') // This picks up the dll since it's in this directory. Doesn't work if you specify the dll by name.
17+
// Fetch the framework jar file
18+
compile 'com.github.RLBot:RLBot:v4-SNAPSHOT'
19+
20+
// Fetch the framework zip file. This will automatically stay up-to-date with the latest changes in the v4 branch.
21+
// This is useful for automatically getting fixes when the framework breaks due to Rocket League patches.
22+
// For different behavior, e.g. freezing at a specific version of the framework, see https://jitpack.io/docs/
23+
compile 'com.github.RLBot:RLBot:v4-SNAPSHOT:python@zip'
24+
25+
// This picks up the dll since it's in this directory. Doesn't work if you specify the dll by name.
26+
runtime files('build/framework/RLBotFramework/dll')
2027
}
2128

2229
def findFile(suffix) {
2330
configurations.compile.filter { it.name.endsWith(suffix) }
2431
}
2532

26-
task assemblePython(type: Copy) {
33+
// Extracts the RLBot framework zip into a directory in ./build/framework so it can be used by the bot.
34+
task prepareFrameworkDirectory(type: Copy) {
2735
from zipTree(findFile('python.zip').singleFile)
2836
into 'build/framework'
2937
}
3038

31-
processResources.dependsOn assemblePython
39+
// Uses pip (the python package manager) to install all the python packages needed for this bot, as defined
40+
// in requirements.txt.
41+
task pipInstallRequirements(type: Exec) {
42+
commandLine "pip", "install", "-r", "requirements.txt"
43+
}
44+
45+
// Installs or updates RLBot. Empty task for now. It still does stuff because it "dependsOn" tasks that do things.
46+
task updateRLBot
47+
updateRLBot.dependsOn pipInstallRequirements
48+
updateRLBot.dependsOn prepareFrameworkDirectory
3249

50+
// Must prepare the framework directory before running pip because the requirements.txt file references another one
51+
// inside the framework directory.
52+
pipInstallRequirements.dependsOn prepareFrameworkDirectory

requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Include everything the framework requires
2+
-r build/framework/requirements.txt

run-bot.bat

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
@rem Change the working directory to the location of this file so that relative paths will work
2+
cd /D "%~dp0"
3+
4+
call ./gradlew.bat --no-daemon updateRLBot
5+
6+
call ./gradlew.bat --no-daemon run

run-framework.bat

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
@rem Change the working directory to the location of this file so that relative paths will work
2+
cd /D "%~dp0"
3+
4+
call ./gradlew.bat --no-daemon updateRLBot
5+
6+
python ./build/framework/runner.py

run.py

Lines changed: 0 additions & 6 deletions
This file was deleted.

src/main/java/rlbot/SampleBot.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,15 @@ public int getIndex() {
4343

4444
@Override
4545
public GameData.ControllerState processInput(GameData.GameTickPacket gameTickPacket) {
46+
if (gameTickPacket.getPlayersCount() <= playerIndex) {
47+
// return no output because the gameTickPacket does not have any info on our car (game hasn't started yet?)
48+
return ControlsOutput.NO_OUTPUT.toControllerState();
49+
}
4650
DataPacket dataPacket = new DataPacket(gameTickPacket, playerIndex);
4751
return processInput(dataPacket).toControllerState();
4852
}
4953

5054
public void retire() {
55+
System.out.println("Retiring sample bot " + playerIndex);
5156
}
5257
}

src/main/java/rlbot/output/ControlsOutput.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
public class ControlsOutput {
66

7+
public static final ControlsOutput NO_OUTPUT = new ControlsOutput();
8+
79
// 0 is straight, -1 is hard left, 1 is hard right.
810
private float steer;
911

0 commit comments

Comments
 (0)