Skip to content

Commit 3d915a3

Browse files
authored
Merge pull request #174 from jCodingStuff/FixCommentsKaspar
Added some more comments.
2 parents 9e910d5 + fc96a17 commit 3d915a3

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

core/src/com/group/golf/ai/PledgeBot.java

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,6 @@
55

66
import com.badlogic.gdx.math.Rectangle;
77
import 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-
*/
138
import com.badlogic.gdx.math.Vector2;
149
import com.group.golf.Ball;
1510
import 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 its 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

Comments
 (0)