Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/main/java/rlbotexample/JavaExample.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,23 @@
*/
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;
});

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);

Expand Down
1 change: 1 addition & 0 deletions src/main/java/rlbotexample/SampleBot.java
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ public ControllerState processInput(GameTickPacket packet) {
return controlsOutput;
}

@Override
public void retire() {
System.out.println("Retiring sample bot " + playerIndex);
}
Expand Down
1 change: 1 addition & 0 deletions src/main/java/rlbotexample/SamplePythonInterface.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
11 changes: 6 additions & 5 deletions src/main/java/rlbotexample/boost/BoostManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -17,15 +18,15 @@
*/
public class BoostManager {

private static final ArrayList<BoostPad> orderedBoosts = new ArrayList<>();
private static final ArrayList<BoostPad> fullBoosts = new ArrayList<>();
private static final ArrayList<BoostPad> smallBoosts = new ArrayList<>();
private static final List<BoostPad> orderedBoosts = new ArrayList<>();
private static final List<BoostPad> fullBoosts = new ArrayList<>();
private static final List<BoostPad> smallBoosts = new ArrayList<>();

public static ArrayList<BoostPad> getFullBoosts() {
public static List<BoostPad> getFullBoosts() {
return fullBoosts;
}

public static ArrayList<BoostPad> getSmallBoosts() {
public static List<BoostPad> getSmallBoosts() {
return smallBoosts;
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/rlbotexample/output/ControlsOutput.java
Original file line number Diff line number Diff line change
Expand Up @@ -146,4 +146,4 @@ public boolean holdHandbrake() {
public boolean holdUseItem() {
return useItemDepressed;
}
}
}
5 changes: 5 additions & 0 deletions src/main/java/rlbotexample/vector/Vector2.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
5 changes: 5 additions & 0 deletions src/main/java/rlbotexample/vector/Vector3.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}