Search in sources :

Example 1 with GameActionSpaceAdapterMulti

use of evodef.GameActionSpaceAdapterMulti in project SimpleAsteroids by ljialin.

the class Agent method setSequenceLength.

public Agent setSequenceLength(int sequenceLength) {
    this.sequenceLength = sequenceLength;
    gameAdapter = new GameActionSpaceAdapterMulti(stateObservationMulti, sequenceLength, id, oppID);
    return this;
}
Also used : GameActionSpaceAdapterMulti(evodef.GameActionSpaceAdapterMulti)

Example 2 with GameActionSpaceAdapterMulti

use of evodef.GameActionSpaceAdapterMulti in project SimpleAsteroids by ljialin.

the class EvoSequenceTest method main.

// simple example of NOT doing rolling horizon, but instead
// of evolving a complete sequence
public static void main(String[] args) throws Exception {
    GameState game = new GameState().defaultState();
    int nResamples = 1;
    EvoAlg evoAlg = new SimpleRMHC(nResamples);
    int nEvals = 2000;
    int seqLength = 30;
    // evoAlg = new SlidingMeanEDA().setHistoryLength(20);
    System.out.println("Initial score: " + game.getScore());
    EvoAgent evoAgent = new EvoAgent().setEvoAlg(evoAlg, nEvals).setSequenceLength(seqLength);
    int[] seq = evoAgent.getActions(game.copy(), 0);
    // System.out.println(evoAgent.simpleGameAdapter.logger().fa);
    // new JEasyFrame( LineChart.easyPlot(evoAgent.simpleGameAdapter.logger().fa), "Evo Plot");
    // visiPlay(game, seq);
    // check the sequence fitness
    System.out.println(evoAgent.simpleGameAdapter.logger().ss);
    System.out.println("Returned sequence: " + Arrays.toString(seq));
    for (int i = 0; i < 5; i++) {
        System.out.println(evoAgent.simpleGameAdapter.evaluate(seq));
    }
    System.out.println();
    System.out.println("Now using the other one");
    for (int i = 0; i < 5; i++) {
        PlanetWarsLinkState linkState = new PlanetWarsLinkState(game.copy());
        GameActionSpaceAdapterMulti adapter = new GameActionSpaceAdapterMulti(linkState, seqLength, 0, 1);
        System.out.println(adapter.evaluate(seq));
    }
    System.out.println();
    for (int i = 0; i < 5; i++) {
        System.out.println(evoAgent.simpleGameAdapter.evaluate(seq));
    }
    System.out.println();
}
Also used : SimpleRMHC(ga.SimpleRMHC) GameActionSpaceAdapterMulti(evodef.GameActionSpaceAdapterMulti) PlanetWarsLinkState(gvglink.PlanetWarsLinkState) EvoAlg(evodef.EvoAlg)

Aggregations

GameActionSpaceAdapterMulti (evodef.GameActionSpaceAdapterMulti)2 EvoAlg (evodef.EvoAlg)1 SimpleRMHC (ga.SimpleRMHC)1 PlanetWarsLinkState (gvglink.PlanetWarsLinkState)1