Search in sources :

Example 1 with DefaultParams

use of evogame.DefaultParams 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 DefaultParams

use of evogame.DefaultParams 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 DefaultParams

use of evogame.DefaultParams 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

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