55
66import com .badlogic .gdx .math .Rectangle ;
77import com .badlogic .gdx .math .Vector2 ;
8- /**
9- * Class to generate instances of PledgeBot
10- * @author Kaspar Kallast
11- * @version 0.2, 19-06-2018
12- */
138import com .badlogic .gdx .math .Vector2 ;
149import com .group .golf .Ball ;
1510import com .group .golf .Course ;
@@ -33,7 +28,7 @@ public class PledgeBot implements Bot {
3328 private Line2D right ;
3429 private Line2D forward ;
3530 private Line2D left ;
36- private float lineLength = 38 ; // By default it� s 30.
31+ private float lineLength = 38 ; // By default it' s 30.
3732 private int currentDir = 0 ;
3833 private float extraHitPower = 0 ;
3934 private int extraHitPowerCount = 0 ;
@@ -105,6 +100,7 @@ public void makeMove() {
105100 }
106101
107102 // System.out.println("extraHitPowerCount: " + extraHitPowerCount);
103+ // If ball is repeating movement then hit it in a random direction.
108104 if (repeat && repeatCount > 1 ) {
109105 this .engine .hit (this .ball ,(float )(Math .random () * ((upperBounda - lowerBounda ) + 1 ) + lowerBounda ), (float )(Math .random () * ((upperBounda - lowerBounda ) + 1 ) + lowerBounda ));
110106 extraHitPowerCounta = 0 ;
@@ -113,6 +109,7 @@ public void makeMove() {
113109
114110 // 0 = forward, 1 = left, 2 = bot, 3 = right the 'way' the ball is 'facing'.
115111 if (cancelHit == false ) {
112+ // If the ball is close enough to the goal then hit the ball towards the goal.
116113 if (goalBallDistance () < distanceLimit ) {
117114 float hitScalar = (float ) 0.065 ;
118115
@@ -129,6 +126,7 @@ public void makeMove() {
129126 float [] distances = new float [] {aGoal -a , bGoal -b };
130127 this .engine .hit (this .ball , distances [0 ]*hitScalar , distances [1 ]*hitScalar );
131128 }
129+ // Check if a certain direction is open and then hit the ball in that direction.
132130 else if (currentDir == 0 ) {
133131 if (rightClear ()) {
134132 this .engine .hit (this .ball ,hitForce + extraHitPower , 0 );
@@ -236,8 +234,6 @@ private void placeRect(float x, float y) {
236234 walls .add (rect );
237235 }
238236
239- // Check for movement repetition
240-
241237 /**
242238 * Check for movement repetition
243239 * @param tracker
0 commit comments