Allow users to choose timescale of race playback. Playback is ~1 min by default, real-time selected with command line variable '-5'. Rescaled race marker positions to distances appropriate for a ~5 minute race.
This commit is contained in:
@@ -4,25 +4,28 @@ public class App
|
|||||||
{
|
{
|
||||||
public static void main( String[] args )
|
public static void main( String[] args )
|
||||||
{
|
{
|
||||||
|
int factor = 200; // Scale 5 min to 1 min
|
||||||
|
if(args.length > 0 && args[0].equals("-5")) factor = 1000; // 1:1 scale
|
||||||
|
|
||||||
Boat[] boats = {
|
Boat[] boats = {
|
||||||
new Boat("ORACLE TEAM USA", 10),
|
new Boat("ORACLE TEAM USA", 11),
|
||||||
new Boat("Artemis Racing", 8),
|
new Boat("Artemis Racing", 10),
|
||||||
new Boat("Emirates Team New Zealand", 12),
|
new Boat("Emirates Team New Zealand", 12),
|
||||||
new Boat("Groupama Team France", 11),
|
new Boat("Groupama Team France", 11.5),
|
||||||
new Boat("Land Rover BAR", 10),
|
new Boat("Land Rover BAR", 11),
|
||||||
new Boat("SoftBank Team Japan", 9)
|
new Boat("SoftBank Team Japan", 10.5)
|
||||||
};
|
};
|
||||||
|
|
||||||
RaceMarker[] marks = {
|
RaceMarker[] marks = {
|
||||||
new RaceMarker("Start", 0, 0, 59),
|
new RaceMarker("Start", 0, 0, 295),
|
||||||
new RaceMarker("Mark", 72, 72, 50),
|
new RaceMarker("Mark", 360, 360, 250),
|
||||||
new RaceMarker("Leeward Gate", 193, 126, 158),
|
new RaceMarker("Leeward Gate", 965, 630, 790),
|
||||||
new RaceMarker("Windward Gate", 373, 41, 0),
|
new RaceMarker("Windward Gate", 1865, 205, 0),
|
||||||
new RaceMarker("Leeward Gate", 553, 126, 158),
|
new RaceMarker("Leeward Gate", 2765, 630, 790),
|
||||||
new RaceMarker("Finish", 607, 95, 203)
|
new RaceMarker("Finish", 3035, 475, 1015)
|
||||||
};
|
};
|
||||||
|
|
||||||
Race race = new ConstantVelocityRace(boats, marks);
|
Race race = new ConstantVelocityRace(boats, marks, factor);
|
||||||
race.simulateRace();
|
race.simulateRace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ import java.util.Collections;
|
|||||||
* Created by cbt24 on 6/03/17.
|
* Created by cbt24 on 6/03/17.
|
||||||
*/
|
*/
|
||||||
public class ConstantVelocityRace extends Race {
|
public class ConstantVelocityRace extends Race {
|
||||||
public ConstantVelocityRace(Boat[] boats, RaceMarker[] marks) {
|
public ConstantVelocityRace(Boat[] boats, RaceMarker[] marks, int factor) {
|
||||||
super(boats, marks);
|
super(boats, marks, factor);
|
||||||
generateRace();
|
generateRace();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,12 +9,15 @@ import java.util.*;
|
|||||||
public class Race {
|
public class Race {
|
||||||
Boat[] boats;
|
Boat[] boats;
|
||||||
RaceMarker[] marks;
|
RaceMarker[] marks;
|
||||||
|
int factor;
|
||||||
|
|
||||||
LinkedList<Event> events = new LinkedList<Event>();
|
LinkedList<Event> events = new LinkedList<Event>();
|
||||||
Timer timer = new Timer();
|
Timer timer = new Timer();
|
||||||
|
|
||||||
public Race(Boat[] boats, RaceMarker[] marks){
|
public Race(Boat[] boats, RaceMarker[] marks, int factor) {
|
||||||
this.boats = boats;
|
this.boats = boats;
|
||||||
this.marks = marks;
|
this.marks = marks;
|
||||||
|
this.factor = factor;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void simulateRace(){
|
public void simulateRace(){
|
||||||
@@ -34,7 +37,7 @@ public class Race {
|
|||||||
public void run(){
|
public void run(){
|
||||||
System.out.println(event);
|
System.out.println(event);
|
||||||
}
|
}
|
||||||
}, event.getTime() * 1000);
|
}, event.getTime() * factor);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -55,7 +58,7 @@ public class Race {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, (events.getLast().getTime() + 1) * 1000);
|
}, (events.getLast().getTime() + 1) * factor);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,8 +7,8 @@ import java.util.Random;
|
|||||||
* Created by cbt24 on 6/03/17.
|
* Created by cbt24 on 6/03/17.
|
||||||
*/
|
*/
|
||||||
public class RandomisedRace extends Race {
|
public class RandomisedRace extends Race {
|
||||||
public RandomisedRace(Boat[] boats, RaceMarker[] marks) {
|
public RandomisedRace(Boat[] boats, RaceMarker[] marks, int factor) {
|
||||||
super(boats, marks);
|
super(boats, marks, factor);
|
||||||
generateRace();
|
generateRace();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user