Search in sources :

Example 1 with GameParameters

use of evogame.GameParameters in project SimpleAsteroids by ljialin.

the class GameSpeedTest method main.

// todo: Fix the error that at the moment
// the ship is not turning to avoid collisions
// at all, depsite the fact that the collisions
// are costly
// why could that be?
public static void main(String[] args) {
    ElapsedTimer timer = new ElapsedTimer();
    boolean visible = true;
    int nTicks = 1000;
    int startLevel = 1;
    int nLives = 3;
    GameParameters params = new GameParameters().injectValues(new DefaultParams());
    AsteroidsGameState gameState = new AsteroidsGameState().setParams(params);
    gameState.initialLevel = 5;
    Game game = new Game(gameState, visible);
    gameState.forwardModel.nLives = nLives;
    Game.copyTest = true;
    ElapsedTimer t = new ElapsedTimer();
    game.run(nTicks);
    System.out.println(t);
    System.out.println(timer);
}
Also used : GameParameters(evogame.GameParameters) DefaultParams(evogame.DefaultParams) ElapsedTimer(utilities.ElapsedTimer)

Example 2 with GameParameters

use of evogame.GameParameters in project SimpleAsteroids by ljialin.

the class EvoAgentTest method main.

// todo: fix an error where whne an Asteroid is hit, it all goes crazy
// like it fails to remove the dead ones
// which is actually exactly what does happen!!
public static void main(String[] args) {
    ElapsedTimer timer = new ElapsedTimer();
    boolean visible = false;
    int nTicks = 1000;
    int startLevel = 1;
    int nLives = 3;
    GameParameters params = new GameParameters().injectValues(new DefaultParams());
    AsteroidsGameState gameState = new AsteroidsGameState().setParams(params);
    gameState.initialLevel = 5;
    Game game = new Game(gameState, visible);
    gameState.forwardModel.nLives = nLives;
    Game.copyTest = false;
    ElapsedTimer t = new ElapsedTimer();
    game.run(nTicks);
    System.out.println(t);
    System.out.println(timer);
}
Also used : GameParameters(evogame.GameParameters) DefaultParams(evogame.DefaultParams) ElapsedTimer(utilities.ElapsedTimer)

Example 3 with GameParameters

use of evogame.GameParameters in project SimpleAsteroids by ljialin.

the class Game method main.

public static void main(String[] args) {
    System.out.println(font);
    boolean visible = true;
    int nTicks = 20000;
    int startLevel = 4;
    int nLives = 5;
    GameParameters params = new GameParameters();
    // AsteroidsGameState gameState = new AsteroidsGameState(params, startLevel, nLives);
    AsteroidsGameState gameState = new AsteroidsGameState().setParams(params).initForwardModel();
    Game game = new Game(gameState, visible);
    ElapsedTimer t = new ElapsedTimer();
    System.out.println("Level = " + gameState.forwardModel.level);
    game.run(nTicks);
    System.out.println(t);
// if (visible) {
// gameState.run(nTicks);
// } else {
// ElapsedTimer t = new ElapsedTimer();
// gameState.runHeadless(nTicks);
// System.out.println(t);
// }
}
Also used : GameParameters(evogame.GameParameters) ElapsedTimer(utilities.ElapsedTimer)

Example 4 with GameParameters

use of evogame.GameParameters in project SimpleAsteroids by ljialin.

the class GameRunner method runTrial.

public static double runTrial(SimplePlayerInterface agent, int nTicks) {
    AsteroidsGameState gameState = new AsteroidsGameState();
    gameState.initialLevel = 5;
    gameState.initialLives = 3;
    GameParameters params = new GameParameters().injectValues(new DefaultParams());
    gameState.setParams(params).initForwardModel();
    gameState.state = State.Playing;
    System.out.println("Level = " + gameState.forwardModel.level);
    while (nTicks-- > 0 && gameState.gameOn()) {
        int action = agent.getAction(gameState.copy(), 0);
        int[] actions = { action };
        gameState.next(actions);
    }
    // System.out.println();
    return gameState.getScore();
}
Also used : GameParameters(evogame.GameParameters) DefaultParams(evogame.DefaultParams)

Aggregations

GameParameters (evogame.GameParameters)4 DefaultParams (evogame.DefaultParams)3 ElapsedTimer (utilities.ElapsedTimer)3