use of gvglink.PlanetWarsLinkState in project SimpleAsteroids by ljialin.
the class GameRunnerTest method getMCTSAgent.
static GVGAIWrapper getMCTSAgent(GameState gameState, int playerId) {
ElapsedCpuTimer timer = new ElapsedCpuTimer();
PlanetWarsLinkState linkState = new PlanetWarsLinkState(gameState);
AbstractMultiPlayer agent = new controllers.multiPlayer.discountOLMCTS.Agent(linkState.copy(), timer, playerId);
GVGAIWrapper wrapper = new GVGAIWrapper().setAgent(agent);
return wrapper;
}
use of gvglink.PlanetWarsLinkState 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();
}
use of gvglink.PlanetWarsLinkState in project SimpleAsteroids by ljialin.
the class GVGAIWrapper method getAction.
@Override
public int getAction(AbstractGameState gameState, int playerId) {
PlanetWarsLinkState linkState = new PlanetWarsLinkState(gameState);
ElapsedCpuTimer timer = new ElapsedCpuTimer();
timer.setMaxTimeMillis(thinkingTime);
Types.ACTIONS actions = agent.act(linkState, timer);
return actions.ordinal();
}
Aggregations