From 262d423913f453614ef4fa86923494f09d722e33 Mon Sep 17 00:00:00 2001 From: Robbie Date: Wed, 2 Oct 2019 16:15:04 +0100 Subject: [PATCH 1/7] Let Eclipse generate its mess. This will be reverted by the end. --- .classpath | 18 +++++++++++++++++ .project | 23 ++++++++++++++++++++++ .settings/org.eclipse.buildship.core.prefs | 2 ++ bin/.gitignore | 1 + 4 files changed, 44 insertions(+) create mode 100644 .classpath create mode 100644 .project create mode 100644 .settings/org.eclipse.buildship.core.prefs create mode 100644 bin/.gitignore diff --git a/.classpath b/.classpath new file mode 100644 index 0000000..467ef2f --- /dev/null +++ b/.classpath @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + diff --git a/.project b/.project new file mode 100644 index 0000000..501f9e2 --- /dev/null +++ b/.project @@ -0,0 +1,23 @@ + + + RLBotJavaExample + Project RLBotJavaExample created by Buildship. + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.buildship.core.gradleprojectbuilder + + + + + + org.eclipse.jdt.core.javanature + org.eclipse.buildship.core.gradleprojectnature + + diff --git a/.settings/org.eclipse.buildship.core.prefs b/.settings/org.eclipse.buildship.core.prefs new file mode 100644 index 0000000..e889521 --- /dev/null +++ b/.settings/org.eclipse.buildship.core.prefs @@ -0,0 +1,2 @@ +connection.project.dir= +eclipse.preferences.version=1 diff --git a/bin/.gitignore b/bin/.gitignore new file mode 100644 index 0000000..ddf9c65 --- /dev/null +++ b/bin/.gitignore @@ -0,0 +1 @@ +/main/ From a8bb83df13a6512975079861ea9dbaeef7cfe7d1 Mon Sep 17 00:00:00 2001 From: Robbie Date: Wed, 2 Oct 2019 16:16:41 +0100 Subject: [PATCH 2/7] Create separate packages for the different aspects of the custom data format. Currently just separating the BallData class from the CarData and CarOrientation classes, away from the DataPacket class. --- src/main/java/rlbotexample/SampleBot.java | 2 +- src/main/java/rlbotexample/input/DataPacket.java | 2 ++ src/main/java/rlbotexample/input/{ => ball}/BallData.java | 2 +- src/main/java/rlbotexample/input/{ => car}/CarData.java | 2 +- src/main/java/rlbotexample/input/{ => car}/CarOrientation.java | 2 +- 5 files changed, 6 insertions(+), 4 deletions(-) rename src/main/java/rlbotexample/input/{ => ball}/BallData.java (94%) 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..3ca6ddb 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; 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 94% rename from src/main/java/rlbotexample/input/BallData.java rename to src/main/java/rlbotexample/input/ball/BallData.java index c7f042f..3252ab0 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; 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 9dfc6a3156f97e29cc97e3162fab8184a55586a7 Mon Sep 17 00:00:00 2001 From: Robbie Date: Wed, 2 Oct 2019 16:26:36 +0100 Subject: [PATCH 3/7] Add a BallTouch class --- .../rlbotexample/input/ball/BallData.java | 4 +++ .../rlbotexample/input/ball/BallTouch.java | 29 +++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 src/main/java/rlbotexample/input/ball/BallTouch.java diff --git a/src/main/java/rlbotexample/input/ball/BallData.java b/src/main/java/rlbotexample/input/ball/BallData.java index 3252ab0..e2f375e 100644 --- a/src/main/java/rlbotexample/input/ball/BallData.java +++ b/src/main/java/rlbotexample/input/ball/BallData.java @@ -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(); + } +} From fdc0167fb0abf8084ec5026983dc8633e0358790 Mon Sep 17 00:00:00 2001 From: Robbie Date: Wed, 2 Oct 2019 16:34:16 +0100 Subject: [PATCH 4/7] Add a rendering example Draws text on the ball to represent how many whole seconds ago the ball was last touched, and in the colour of the team that touched it I also forced myself to use "color" rather than "colour" :angry: --- src/main/java/rlbotexample/SampleBot.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/java/rlbotexample/SampleBot.java b/src/main/java/rlbotexample/SampleBot.java index 3ca6ddb..2c014f9 100644 --- a/src/main/java/rlbotexample/SampleBot.java +++ b/src/main/java/rlbotexample/SampleBot.java @@ -74,6 +74,12 @@ private void drawDebugLines(DataPacket input, CarData myCar, boolean goLeft) { myCar.position.plus(myCar.orientation.noseVector.scaled(300))); 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 From f34134b1e941a7b004130f0e18cb084e1cbf1273 Mon Sep 17 00:00:00 2001 From: Robbie Date: Wed, 2 Oct 2019 16:36:49 +0100 Subject: [PATCH 5/7] Correct my indentation --- src/main/java/rlbotexample/input/ball/BallData.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/rlbotexample/input/ball/BallData.java b/src/main/java/rlbotexample/input/ball/BallData.java index e2f375e..8dffab4 100644 --- a/src/main/java/rlbotexample/input/ball/BallData.java +++ b/src/main/java/rlbotexample/input/ball/BallData.java @@ -14,8 +14,8 @@ public class BallData { public final Vector3 position; public final Vector3 velocity; public final Vector3 spin; - public final BallTouch latestTouch; - public final boolean hasBeenTouched; + public final BallTouch latestTouch; + public final boolean hasBeenTouched; public BallData(final BallInfo ball) { this.position = new Vector3(ball.physics().location()); From c5a6d1c6877edfdcda1b4118f831fb54c03bdd60 Mon Sep 17 00:00:00 2001 From: Robbie Date: Wed, 2 Oct 2019 16:37:37 +0100 Subject: [PATCH 6/7] Revert "Let Eclipse generate its mess." This reverts commit 262d423913f453614ef4fa86923494f09d722e33. --- .classpath | 18 ----------------- .project | 23 ---------------------- .settings/org.eclipse.buildship.core.prefs | 2 -- bin/.gitignore | 1 - 4 files changed, 44 deletions(-) delete mode 100644 .classpath delete mode 100644 .project delete mode 100644 .settings/org.eclipse.buildship.core.prefs delete mode 100644 bin/.gitignore diff --git a/.classpath b/.classpath deleted file mode 100644 index 467ef2f..0000000 --- a/.classpath +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - - - - - - - - diff --git a/.project b/.project deleted file mode 100644 index 501f9e2..0000000 --- a/.project +++ /dev/null @@ -1,23 +0,0 @@ - - - RLBotJavaExample - Project RLBotJavaExample created by Buildship. - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.buildship.core.gradleprojectbuilder - - - - - - org.eclipse.jdt.core.javanature - org.eclipse.buildship.core.gradleprojectnature - - diff --git a/.settings/org.eclipse.buildship.core.prefs b/.settings/org.eclipse.buildship.core.prefs deleted file mode 100644 index e889521..0000000 --- a/.settings/org.eclipse.buildship.core.prefs +++ /dev/null @@ -1,2 +0,0 @@ -connection.project.dir= -eclipse.preferences.version=1 diff --git a/bin/.gitignore b/bin/.gitignore deleted file mode 100644 index ddf9c65..0000000 --- a/bin/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/main/ From 431f16f931935d4c4bb75c9fef211c7710dd1f8b Mon Sep 17 00:00:00 2001 From: Robbie Date: Wed, 2 Oct 2019 16:42:10 +0100 Subject: [PATCH 7/7] Fix my indentation (again) --- src/main/java/rlbotexample/SampleBot.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/rlbotexample/SampleBot.java b/src/main/java/rlbotexample/SampleBot.java index 2c014f9..80c5e3d 100644 --- a/src/main/java/rlbotexample/SampleBot.java +++ b/src/main/java/rlbotexample/SampleBot.java @@ -74,11 +74,11 @@ private void drawDebugLines(DataPacket input, CarData myCar, boolean goLeft) { myCar.position.plus(myCar.orientation.noseVector.scaled(300))); 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); + 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 {