Search in sources :

Example 1 with AsteroidsGameState

use of asteroids.AsteroidsGameState in project SimpleAsteroids by ljialin.

the class ParameterSettingsTest method main.

public static void main(String[] args) {
    DefaultParams defParams = new DefaultParams();
    defParams.shipSteer = 1;
    // GameParameters params = new GameParameters().injectValues(evolvableParams);
    GameParameters params = new GameParameters().injectValues(defParams);
    SimpleEvaluator eval = new SimpleEvaluator();
    int nTrials = 30;
    eval.evaluate(defParams, nTrials);
    // exit if we're done
    // comment this out to proceed to visual test
    // System.exit(0);
    int startLevel = 1;
    int nLives = 5;
    boolean visible = true;
    int nTicks = 10000;
    AsteroidsGameState gameState = new AsteroidsGameState().setParams(params).initForwardModel();
    Game game = new Game(gameState, visible);
    ElapsedTimer t = new ElapsedTimer();
    game.run(nTicks);
    System.out.println(t);
// System.out.println(gameState.score);
}
Also used : Game(asteroids.Game) ElapsedTimer(utilities.ElapsedTimer) AsteroidsGameState(asteroids.AsteroidsGameState)

Example 2 with AsteroidsGameState

use of asteroids.AsteroidsGameState in project SimpleAsteroids by ljialin.

the class EvoAgentSearchSpaceAsteroids method evaluate.

@Override
public double evaluate(int[] x) {
    // create a problem to evaluate this one on ...
    // this should really be set externally, but just doing it this way for now
    AsteroidsGameState gameState = new AsteroidsGameState().setParams(params).initForwardModel();
    // search space will need to be set before use
    DefaultMutator mutator = new DefaultMutator(null);
    mutator.pointProb = pointMutationRate[x[pointMutationRateIndex]];
    mutator.flipAtLeastOneValue = flipAtLeastOneBit[x[flipAtLeastOneBitIndex]];
    // setting to true may give best performance
    mutator.totalRandomChaosMutation = false;
    SimpleRMHC simpleRMHC = new SimpleRMHC();
    simpleRMHC.setSamplingRate(nResamples[x[nResamplesIndex]]);
    simpleRMHC.setMutator(mutator);
    EvoAlg sliding = new SlidingMeanEDA();
    EvoAgent evoAgent = new EvoAgent().setEvoAlg(simpleRMHC, getNEvals(x));
    // EvoAgent evoAgent = new EvoAgent().setEvoAlg(sliding, getNEvals(x));
    evoAgent.setUseShiftBuffer(useShiftBuffer[x[useShiftBufferIndex]]);
    evoAgent.setSequenceLength(seqLength[x[seqLengthIndex]]);
    for (int i = 0; i < maxTick; i++) {
        int action = evoAgent.getAction(gameState, 0);
        gameState.next(new int[] { action });
    }
    double fitness = gameState.getScore();
    logger.log(fitness, x, false);
    return fitness;
}
Also used : SimpleRMHC(ga.SimpleRMHC) DefaultMutator(evodef.DefaultMutator) SlidingMeanEDA(ntuple.SlidingMeanEDA) AsteroidsGameState(asteroids.AsteroidsGameState)

Example 3 with AsteroidsGameState

use of asteroids.AsteroidsGameState in project SimpleAsteroids by ljialin.

the class RandomTestAsteroids method evaluate.

public static double evaluate(SimplePlayerInterface player) {
    // create a problem to evaluate this one on ...
    // this should really be set externally, but just doing it this way for now
    AsteroidsGameState gameState = new AsteroidsGameState().setParams(params).initForwardModel();
    for (int i = 0; i < maxTick; i++) {
        int action = player.getAction(gameState, 0);
        gameState.next(new int[] { action });
    }
    double fitness = gameState.getScore();
    return fitness;
}
Also used : AsteroidsGameState(asteroids.AsteroidsGameState)

Aggregations

AsteroidsGameState (asteroids.AsteroidsGameState)3 Game (asteroids.Game)1 DefaultMutator (evodef.DefaultMutator)1 SimpleRMHC (ga.SimpleRMHC)1 SlidingMeanEDA (ntuple.SlidingMeanEDA)1 ElapsedTimer (utilities.ElapsedTimer)1