|
|
|
@ -362,11 +362,7 @@ public class MockRace extends RaceState {
|
|
|
|
setBoatSpeed(boat);
|
|
|
|
setBoatSpeed(boat);
|
|
|
|
|
|
|
|
|
|
|
|
//Calculates the distance travelled, in meters, in the current timeslice.
|
|
|
|
//Calculates the distance travelled, in meters, in the current timeslice.
|
|
|
|
double distanceTravelledMeters = boat.calculateMetersTravelled(updatePeriodMilliseconds);
|
|
|
|
double distanceTravelledMeters = boat.calculateMetersTravelled(updatePeriodMilliseconds) * this.scaleFactor;
|
|
|
|
|
|
|
|
|
|
|
|
//Scale it.
|
|
|
|
|
|
|
|
distanceTravelledMeters = distanceTravelledMeters * this.scaleFactor;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Move the boat forwards that many meters, and advances its time counters by enough milliseconds.
|
|
|
|
//Move the boat forwards that many meters, and advances its time counters by enough milliseconds.
|
|
|
|
boat.moveForwards(distanceTravelledMeters);
|
|
|
|
boat.moveForwards(distanceTravelledMeters);
|
|
|
|
@ -388,32 +384,12 @@ public class MockRace extends RaceState {
|
|
|
|
private void newOptimalVMG(MockBoat boat) {
|
|
|
|
private void newOptimalVMG(MockBoat boat) {
|
|
|
|
long tackPeriod = 1000;
|
|
|
|
long tackPeriod = 1000;
|
|
|
|
if (boat.getTimeSinceTackChange() > tackPeriod) {
|
|
|
|
if (boat.getTimeSinceTackChange() > tackPeriod) {
|
|
|
|
//System.out.println("optim called");
|
|
|
|
|
|
|
|
//Calculate the new VMG.
|
|
|
|
|
|
|
|
// VMG newVMG = boat.getPolars().calculateVMG(
|
|
|
|
|
|
|
|
// this.getWindDirection(),
|
|
|
|
|
|
|
|
// this.getWindSpeed(),
|
|
|
|
|
|
|
|
// boat.calculateBearingToNextMarker(),
|
|
|
|
|
|
|
|
// Bearing.fromDegrees(0d),
|
|
|
|
|
|
|
|
// Bearing.fromDegrees(359.99999d));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
VMG newVMG = NewPolars.setBestVMG(this.getWindDirection(), this.getWindSpeed(), boat.getBearing());
|
|
|
|
VMG newVMG = NewPolars.setBestVMG(this.getWindDirection(), this.getWindSpeed(), boat.getBearing());
|
|
|
|
//System.out.println(newVMG);
|
|
|
|
|
|
|
|
//If the new vmg improves velocity, use it.
|
|
|
|
|
|
|
|
/*if (improvesVelocity(boat, newVMG)) {
|
|
|
|
|
|
|
|
}*/
|
|
|
|
|
|
|
|
boat.setVMG(newVMG);
|
|
|
|
boat.setVMG(newVMG);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void setBoatSpeed(MockBoat boat) {
|
|
|
|
private void setBoatSpeed(MockBoat boat) {
|
|
|
|
// VMG vmg = boat.getPolars().calculateVMG(
|
|
|
|
|
|
|
|
// this.getWindDirection(),
|
|
|
|
|
|
|
|
// this.getWindSpeed(),
|
|
|
|
|
|
|
|
// boat.getBearing(),
|
|
|
|
|
|
|
|
// Bearing.fromDegrees(boat.getBearing().degrees() - 1),
|
|
|
|
|
|
|
|
// Bearing.fromDegrees(boat.getBearing().degrees() + 1));
|
|
|
|
|
|
|
|
//VMG vmg = boat.getPolars().setBestVMG(this.getWindDirection(), this.getWindSpeed(), boat.getBearing());
|
|
|
|
|
|
|
|
VMG vmg = new VMG(NewPolars.calculateSpeed(
|
|
|
|
VMG vmg = new VMG(NewPolars.calculateSpeed(
|
|
|
|
this.getWindDirection(),
|
|
|
|
this.getWindDirection(),
|
|
|
|
this.getWindSpeed(),
|
|
|
|
this.getWindSpeed(),
|
|
|
|
|