Skip to content
Merged
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
12 changes: 4 additions & 8 deletions core/src/com/group/golf/ai/PledgeBot.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@

import com.badlogic.gdx.math.Rectangle;
import com.badlogic.gdx.math.Vector2;
/**
* Class to generate instances of PledgeBot
* @author Kaspar Kallast
* @version 0.2, 19-06-2018
*/
import com.badlogic.gdx.math.Vector2;
import com.group.golf.Ball;
import com.group.golf.Course;
Expand All @@ -33,7 +28,7 @@ public class PledgeBot implements Bot {
private Line2D right;
private Line2D forward;
private Line2D left;
private float lineLength = 38; // By default its 30.
private float lineLength = 38; // By default it's 30.
private int currentDir = 0;
private float extraHitPower = 0;
private int extraHitPowerCount = 0;
Expand Down Expand Up @@ -105,6 +100,7 @@ public void makeMove() {
}

// System.out.println("extraHitPowerCount: " + extraHitPowerCount);
// If ball is repeating movement then hit it in a random direction.
if (repeat && repeatCount > 1) {
this.engine.hit(this.ball,(float)(Math.random() * ((upperBounda - lowerBounda) + 1) + lowerBounda), (float)(Math.random() * ((upperBounda - lowerBounda) + 1) + lowerBounda));
extraHitPowerCounta = 0;
Expand All @@ -113,6 +109,7 @@ public void makeMove() {

// 0 = forward, 1 = left, 2 = bot, 3 = right the 'way' the ball is 'facing'.
if (cancelHit == false) {
// If the ball is close enough to the goal then hit the ball towards the goal.
if (goalBallDistance() < distanceLimit) {
float hitScalar = (float) 0.065;

Expand All @@ -129,6 +126,7 @@ public void makeMove() {
float[] distances = new float[] {aGoal-a, bGoal-b};
this.engine.hit(this.ball, distances[0]*hitScalar, distances[1]*hitScalar);
}
// Check if a certain direction is open and then hit the ball in that direction.
else if (currentDir == 0) {
if (rightClear()) {
this.engine.hit(this.ball,hitForce + extraHitPower, 0);
Expand Down Expand Up @@ -236,8 +234,6 @@ private void placeRect(float x, float y) {
walls.add(rect);
}

// Check for movement repetition

/**
* Check for movement repetition
* @param tracker
Expand Down