Search in sources :

Example 1 with SimpleBattleState

use of battle.SimpleBattleState 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)

Example 2 with SimpleBattleState

use of battle.SimpleBattleState in project SimpleAsteroids by ljialin.

the class FeatureView method main.

public static void main(String[] args) throws Exception {
    SimpleBattleState state = new SimpleBattleState();
    FeatureView fv = new FeatureView().setBattleState(state);
    new JEasyFrame(fv, "Feature view");
    while (true) {
        Thread.sleep(50);
        asteroids.Action action = new Action(0, 1, false);
        state.ships[0].update(action);
        AgentCentric ac = new AgentCentric(state.ships[0].s, state.ships[0].d);
        Vector2d tmp = ac.transform(state.ships[1].s);
        int r = (int) tmp.mag();
        int theta = (int) (180 * tmp.theta() / Math.PI);
        System.out.println(r + "\t " + theta);
        fv.repaint();
    }
}
Also used : Action(asteroids.Action) JEasyFrame(utilities.JEasyFrame) Vector2d(math.Vector2d) SimpleBattleState(battle.SimpleBattleState) Action(asteroids.Action)

Aggregations

SimpleBattleState (battle.SimpleBattleState)2 Action (asteroids.Action)1 Vector2d (math.Vector2d)1 ElapsedTimer (utilities.ElapsedTimer)1 JEasyFrame (utilities.JEasyFrame)1