use of utilities.ElapsedTimer in project SimpleAsteroids by ljialin.
the class GameRunner method playGames.
public GameRunner playGames(int n) {
// plays an additional n games without resetting the stats
ElapsedTimer t = new ElapsedTimer();
for (int i = 0; i < n; i++) {
playGame();
}
if (verbose) {
System.out.println(p1 + " versus " + p2);
System.out.println(scores);
System.out.println();
System.out.println("p1 wins:\t " + p1Wins);
System.out.println("p2 wins:\t " + p2Wins);
System.out.println("n games:\t " + nGames);
System.out.println("Init leader wins: " + nInitialLeaderWins);
System.out.println(t);
}
System.out.println();
return this;
}
use of utilities.ElapsedTimer in project SimpleAsteroids by ljialin.
the class RandomTestPlanetWars method main.
public static void main(String[] args) {
int nTrials = 100;
SimplePlayerInterface player = new RandomAgent();
StatSummary ss = new StatSummary("Random Player on Planet Wars");
ElapsedTimer t = new ElapsedTimer();
for (int i = 0; i < nTrials; i++) {
ss.add(evaluate(player));
}
System.out.println(ss);
System.out.println();
System.out.println(t);
}
use of utilities.ElapsedTimer in project SimpleAsteroids by ljialin.
the class VoronoiGrid method paintComponent.
public void paintComponent(Graphics go) {
Graphics2D g = (Graphics2D) go;
Dimension d = getSize();
ElapsedTimer timer = new ElapsedTimer();
int nCells = 0;
for (int y = 0; y < d.getHeight(); y += cellSize) {
for (int x = 0; x < d.getWidth(); x += cellSize) {
nCells++;
int closestIndex = getClosestPointIndex(new Vector2d(x, y));
g.setColor(colors.get(closestIndex));
g.fillRect(x, y, cellSize, cellSize);
}
// System.out.println(y);
}
System.out.println("Painted n cells: " + nCells);
System.out.println(timer);
// if (!dimension.equals(d) || )
}
use of utilities.ElapsedTimer in project SimpleAsteroids by ljialin.
the class SimpleClient method main.
public static void main(String[] args) throws Exception {
int nReps = 10;
String hostname = "localhost";
// millis
int delay = 1000;
for (int i = 0; i < nReps; i++) {
Socket socket = new Socket(hostname, SimpleServer.defaultPort);
PrintStream out = new PrintStream(socket.getOutputStream());
Scanner scanner = new Scanner(socket.getInputStream());
ElapsedTimer t = new ElapsedTimer();
out.println("Hello world");
String line = scanner.nextLine();
System.out.println(i + "\t " + line);
System.out.println("Round trip delay: " + t);
socket.close();
Thread.sleep(delay);
}
}
use of utilities.ElapsedTimer in project SimpleAsteroids by ljialin.
the class GameCopyTest method main.
public static void main(String[] args) {
ElapsedTimer timer = new ElapsedTimer();
double gameTick = 40;
int nCopies = (int) 1e7;
// StateObservationMulti game = new SimpleBattleState();
SimpleBattleState game = new SimpleBattleState();
for (int i = 0; i < nCopies; i++) {
game = game.copyState();
// game = game.copy();
}
System.out.format("Made %d copies\n", nCopies);
System.out.format("Copies per milli-second: %.1f\n\n", nCopies / (double) timer.elapsed());
System.out.format("Game tick time = %d ms\n", (int) gameTick);
System.out.format("Copies per game tick: %d\n\n", (int) (gameTick * nCopies / (double) timer.elapsed()));
System.out.println(timer);
}
Aggregations