Search in sources :

Example 1 with ElapsedTimer

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;
}
Also used : ElapsedTimer(utilities.ElapsedTimer)

Example 2 with ElapsedTimer

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);
}
Also used : StatSummary(utilities.StatSummary) ElapsedTimer(utilities.ElapsedTimer)

Example 3 with ElapsedTimer

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) || )
}
Also used : Vector2d(math.Vector2d) ElapsedTimer(utilities.ElapsedTimer)

Example 4 with ElapsedTimer

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);
    }
}
Also used : PrintStream(java.io.PrintStream) Scanner(java.util.Scanner) ElapsedTimer(utilities.ElapsedTimer) Socket(java.net.Socket)

Example 5 with ElapsedTimer

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);
}
Also used : SimpleBattleState(battle.SimpleBattleState) ElapsedTimer(utilities.ElapsedTimer)

Aggregations

ElapsedTimer (utilities.ElapsedTimer)63 StatSummary (utilities.StatSummary)27 Random (java.util.Random)12 SimpleRMHC (ga.SimpleRMHC)9 Types (ontology.Types)9 ElapsedCpuTimer (tools.ElapsedCpuTimer)9 EvoAlg (evodef.EvoAlg)7 NTupleBanditEA (ntuple.NTupleBanditEA)7 JEasyFrame (utilities.JEasyFrame)7 ArrayList (java.util.ArrayList)6 AbstractPlayer (core.player.AbstractPlayer)5 Gson (com.google.gson.Gson)4 Agent (controllers.singlePlayer.ea.Agent)4 StateObservationMulti (core.game.StateObservationMulti)4 StateObservation (core.game.StateObservation)3 AbstractMultiPlayer (core.player.AbstractMultiPlayer)3 GameParameters (evogame.GameParameters)3 ConvNTuple (ntuple.ConvNTuple)3 SlidingMeanEDA (ntuple.SlidingMeanEDA)3 SimpleMaxGame (altgame.SimpleMaxGame)2