From d10d9c25dec386bdd0d64ced810ff610f57c856d Mon Sep 17 00:00:00 2001
From: Tymofii Mazurenko <tymofii.mazurenko@student.griffith.ie>
Date: Sun, 23 Mar 2025 23:40:35 +0000
Subject: [PATCH 1/7] Adding essential imports to the initial structure

---
 PrimeBot.java | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/PrimeBot.java b/PrimeBot.java
index 5df24ca..2da298f 100644
--- a/PrimeBot.java
+++ b/PrimeBot.java
@@ -1,8 +1,24 @@
 package grouphsd1;
 
 import robocode.*;
+import java.awt.Color;
+import java.awt.geom.Point2D;
+import java.awt.geom.Rectangle2D;
+import java.util.Hashtable;
+import robocode.AdvancedRobot;
+import robocode.RobotDeathEvent;
+import robocode.ScannedRobotEvent;
+import robocode.util.Utils;
 
-public class PrimeBot extends Robot {
+/**
+ * PrimeBot - An improved Robocode robot with adaptive movement and targeting
+ *
+ * Strategy:
+ * - Wave surfing movement to avoid enemy fire
+ * - Pattern matching targeting for increased accuracy
+ * - Energy management for optimal firing decisions
+ * - Battlefield awareness for better positioning
+ */
     public void run() {
 
     }
-- 
GitLab


From 1581bc76ddea0a00b4b71fb956b5580607009b45 Mon Sep 17 00:00:00 2001
From: Tymofii Mazurenko <tymofii.mazurenko@student.griffith.ie>
Date: Sun, 23 Mar 2025 23:46:51 +0000
Subject: [PATCH 2/7] Creating color variables for each part of the robot

The colors initialized in robot's appearance
---
 PrimeBot.java | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/PrimeBot.java b/PrimeBot.java
index 2da298f..8299585 100644
--- a/PrimeBot.java
+++ b/PrimeBot.java
@@ -19,6 +19,13 @@ import robocode.util.Utils;
  * - Energy management for optimal firing decisions
  * - Battlefield awareness for better positioning
  */
+public class PrimeBot extends AdvancedRobot {
+    // Colors
+    private final Color bodyColor = new Color(11, 96, 99);
+    private final Color gunColor = new Color(0, 51, 102);
+    private final Color radarColor = new Color(200, 225, 255);
+    private final Color bulletColor = new Color(255, 250, 250);
+    private final Color scanColor = new Color(112, 128, 144);
     public void run() {
 
     }
-- 
GitLab


From 03cf84a8d0461cb15a07bc07f1a8bdf043560a72 Mon Sep 17 00:00:00 2001
From: Tymofii Mazurenko <tymofii.mazurenko@student.griffith.ie>
Date: Sun, 23 Mar 2025 23:53:41 +0000
Subject: [PATCH 3/7] Constants and variables regarding robot's state

Implemented a few constants describing the features that robot will have
in its strategy. Some of the state regarding variables were also added
to the codebase.
---
 PrimeBot.java | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)

diff --git a/PrimeBot.java b/PrimeBot.java
index 8299585..801df26 100644
--- a/PrimeBot.java
+++ b/PrimeBot.java
@@ -26,7 +26,41 @@ public class PrimeBot extends AdvancedRobot {
     private final Color radarColor = new Color(200, 225, 255);
     private final Color bulletColor = new Color(255, 250, 250);
     private final Color scanColor = new Color(112, 128, 144);
+
+    // Constants
+    private static final int EVALUATION_ITERATIONS = 100;
+    private static final double SAFE_DISTANCE_FROM_WALLS = 30.0;
+    private static final double MAX_VELOCITY = 8.0;
+
+    // Robot states
+    private static Hashtable<String, EnemyData> enemies = new Hashtable<>();
+    private static EnemyData currentTarget = new EnemyData();
+    private static Point2D.Double myPosition;
+    private static Point2D.Double lastPosition;
+    private static double myEnergy;
+    private Point2D.Double nextDestination;
+
+    @Override
     public void run() {
+        // Robot initialization
+        setColors(bodyColor, gunColor, radarColor, bulletColor, scanColor);
+        setAdjustGunForRobotTurn(true);
+        setAdjustRadarForGunTurn(true);
+        setTurnRadarRightRadians(Double.POSITIVE_INFINITY);
 
+        // Main robot loop
+        while (true) {
+            // Update position and energy
+            myPosition = new Point2D.Double(getX(), getY());
+            myEnergy = getEnergy();
+
+            // Execute battle strategy if we have a live target and battle has begun
+            if (currentTarget.isLive && getTime() > 9) {
+                executeBattleStrategy();
+            }
+
+            execute();
+        }
     }
+
 }
\ No newline at end of file
-- 
GitLab


From f7b0e6ded88c46c3a50af9bb50ecfb9dd70e8c82 Mon Sep 17 00:00:00 2001
From: Tymofii Mazurenko <tymofii.mazurenko@student.griffith.ie>
Date: Sun, 23 Mar 2025 23:56:57 +0000
Subject: [PATCH 4/7] Execution of the robot

prototype of the execution of the robot strategy
---
 PrimeBot.java | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/PrimeBot.java b/PrimeBot.java
index 801df26..0a1f39c 100644
--- a/PrimeBot.java
+++ b/PrimeBot.java
@@ -63,4 +63,14 @@ public class PrimeBot extends AdvancedRobot {
         }
     }
 
+    /**
+     * Main method to execute the robot's battle strategy
+     */
+    private void executeBattleStrategy() {
+        // Fire control
+        handleGunControl();
+
+        // Movement control
+        handleMovement();
+    }
 }
\ No newline at end of file
-- 
GitLab


From 01ef4ef31a5eb3a11dde3ad8fcbb0e55a25ea3c3 Mon Sep 17 00:00:00 2001
From: Tymofii Mazurenko <tymofii.mazurenko@student.griffith.ie>
Date: Mon, 24 Mar 2025 00:00:46 +0000
Subject: [PATCH 5/7] Added energy management logic and firing control based on
 energy levels

HandleGunControl function that implements firing and energy logic, for
the initial robot's codebase.
---
 PrimeBot.java | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/PrimeBot.java b/PrimeBot.java
index 0a1f39c..d0b9c04 100644
--- a/PrimeBot.java
+++ b/PrimeBot.java
@@ -73,4 +73,29 @@ public class PrimeBot extends AdvancedRobot {
         // Movement control
         handleMovement();
     }
+
+    /**
+     * Controls gun rotation and firing
+     */
+    private void handleGunControl() {
+        Point2D.Double targetPosition = currentTarget.position;
+        double distance = myPosition.distance(targetPosition);
+
+        // Calculate optimal firing power based on distance and energy levels
+        double firePower = Math.min(
+                Math.min(myEnergy / 6.0, 1300.0 / distance),
+                currentTarget.energy / 3.0
+        );
+
+        // Fire when gun is ready and we have sufficient energy
+        if (getGunTurnRemaining() == 0 && myEnergy > 1.0) {
+            setFire(firePower);
+        }
+
+        // Turn gun towards target
+        double gunTurnAngle = Utils.normalRelativeAngle(
+                getGunHeadingRadians() - calcAngle(targetPosition, myPosition)
+        );
+        setTurnGunLeftRadians(gunTurnAngle);
+    }
 }
\ No newline at end of file
-- 
GitLab


From 7f8808065212bc926e68815cf666bb8180c3f719 Mon Sep 17 00:00:00 2001
From: Tymofii Mazurenko <tymofii.mazurenko@student.griffith.ie>
Date: Mon, 24 Mar 2025 00:05:18 +0000
Subject: [PATCH 6/7] Added the math related functions to help calculate angle
 and a point

calcPoint function to calculate the point at some distance.
calcAngle function to calculate the angle between two points.
They are helper math function.
---
 PrimeBot.java | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/PrimeBot.java b/PrimeBot.java
index d0b9c04..44e459f 100644
--- a/PrimeBot.java
+++ b/PrimeBot.java
@@ -98,4 +98,29 @@ public class PrimeBot extends AdvancedRobot {
         );
         setTurnGunLeftRadians(gunTurnAngle);
     }
+
+    /**
+     * Controls robot movement to avoid enemies and walls
+     */
+    private void handleMovement() {
+
+    }
+
+    /**
+     * Calculates a point at specified distance and angle from origin
+     */
+    private static Point2D.Double calcPoint(Point2D.Double origin, double distance, double angle) {
+        return new Point2D.Double(
+                origin.x + distance * Math.sin(angle),
+                origin.y + distance * Math.cos(angle)
+        );
+    }
+
+    /**
+     * Calculates angle between two points
+     */
+    private static double calcAngle(Point2D.Double target, Point2D.Double source) {
+        return Math.atan2(target.x - source.x, target.y - source.y);
+    }
+
 }
\ No newline at end of file
-- 
GitLab


From c946bdc7470e7ecb74bce08530bbeeb53bd3e959 Mon Sep 17 00:00:00 2001
From: Tymofii Mazurenko <tymofii.mazurenko@student.griffith.ie>
Date: Mon, 24 Mar 2025 00:07:36 +0000
Subject: [PATCH 7/7] Implemented EnemyData class for the enemy robot
 information

The class EnemyData is itself a class, that hold the information, for
the enemy robot, that is an enemy for us at the moment.
---
 PrimeBot.java | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/PrimeBot.java b/PrimeBot.java
index 44e459f..b432703 100644
--- a/PrimeBot.java
+++ b/PrimeBot.java
@@ -1,6 +1,5 @@
 package grouphsd1;
 
-import robocode.*;
 import java.awt.Color;
 import java.awt.geom.Point2D;
 import java.awt.geom.Rectangle2D;
@@ -123,4 +122,18 @@ public class PrimeBot extends AdvancedRobot {
         return Math.atan2(target.x - source.x, target.y - source.y);
     }
 
+    /**
+     * Class to store enemy robot data
+     */
+    private static class EnemyData {
+        public String name;
+        public Point2D.Double position;
+        public double energy;
+        public boolean isLive;
+
+        public EnemyData() {
+            this.position = new Point2D.Double();
+            this.isLive = false;
+        }
+    }
 }
\ No newline at end of file
-- 
GitLab