use of core.player.AbstractMultiPlayer in project SimpleAsteroids by ljialin.
the class DiffGameViewTest method main.
public static void main(String[] args) throws Exception {
// stop the game ending
DiffGame.maxTick = 1000000;
DiffGame dg = new DiffGame();
AbstractMultiPlayer player1, player2;
ElapsedCpuTimer timer = new ElapsedCpuTimer();
player1 = new controllers.multiPlayer.sampleRandom.Agent(dg, timer, 0);
player2 = new controllers.multiPlayer.sampleRandom.Agent(dg, timer, 1);
int idPlayer1 = 0;
int idPlayer2 = 1;
// try the evolutionary players
int nResamples = 3;
EvoAlg evoAlg = new SimpleRMHC(nResamples);
EvoAlg evoAlg2 = new SimpleRMHC(nResamples);
double kExplore = 2;
int nNeighbours = 50;
int nEvals = 15000;
// evoAlg = new NTupleBanditEA(kExplore, nNeighbours);
controllers.multiPlayer.ea.Agent agentEAShift = new controllers.multiPlayer.ea.Agent(dg, timer, evoAlg, idPlayer1, nEvals);
agentEAShift.useShiftBuffer = true;
agentEAShift.sequenceLength = 10;
player1 = agentEAShift;
// player2 = new controllers.multiPlayer.discountOLMCTS.Agent(dg, timer, idPlayer2);
// player2 = new controllers.multiPlayer.sampleOLMCTS.Agent(dg, timer, idPlayer2);
controllers.multiPlayer.ea.Agent agentEANoShift = new controllers.multiPlayer.ea.Agent(dg, timer, evoAlg2, idPlayer1, nEvals);
agentEANoShift.useShiftBuffer = true;
agentEANoShift.sequenceLength = 10;
player1 = agentEANoShift;
int nTicks = 250;
int delay = 100;
int updateTick = 1;
DiffGameView view = new DiffGameView(dg);
JEasyFrame frame = new JEasyFrame(view, "Diff Game");
KeyPlayer keyPlayer = new KeyPlayer(view);
frame.addKeyListener(keyPlayer.controller);
// player1 = keyPlayer;
player2 = new ConstantPlayer(2);
Types.ACTIONS[] actions = new Types.ACTIONS[2];
for (int i = 0; i < nTicks; i++) {
// update the chosen actions every so often
if (i % updateTick == 0) {
actions[0] = player1.act(dg.copy(), timer);
actions[1] = player2.act(dg.copy(), timer);
}
// advance anyway
dg.advance(actions);
view.update(dg);
Thread.sleep(delay);
}
System.out.println(dg.getGameScore());
}
use of core.player.AbstractMultiPlayer in project SimpleAsteroids by ljialin.
the class GeneralGameRunnerTest method main.
public static void main(String[] args) {
PlanetWarsLinkState linkState = new PlanetWarsLinkState();
GeneralGameRunner runner = new GeneralGameRunner().setGame(linkState).setLength(200);
AbstractMultiPlayer player1, player2;
GameActionSpaceAdapterMulti.visual = false;
GameState.includeBuffersInScore = false;
int idPlayer1 = 0;
int idPlayer2 = 1;
ElapsedCpuTimer timer = new ElapsedCpuTimer();
player1 = new controllers.multiPlayer.discountOLMCTS.Agent(linkState.copy(), timer, idPlayer1);
// try the evolutionary players
// GameActionSpaceAdapterMulti.visual = true;
int nResamples = 1;
EvoAlg evoAlg = new SimpleRMHC(nResamples);
int nEvals = 200;
EvoAlg evoAlg2 = new SlidingMeanEDA().setHistoryLength(20);
Agent evoAgent1 = new controllers.multiPlayer.ea.Agent(linkState.copy(), timer, evoAlg, idPlayer1, nEvals);
evoAgent1.sequenceLength = 10;
// player1 = evoAgent1;
Agent evoAgent2 = new controllers.multiPlayer.ea.Agent(linkState.copy(), timer, evoAlg, idPlayer2, nEvals);
evoAgent2.sequenceLength = 10;
// evoAgent2.setUseShiftBuffer(false);
player2 = evoAgent2;
// player2 = new controllers.multiPlayer.ea.Agent(linkState, timer, evoAlg2, idPlayer2, nEvals);
// player2 = new controllers.multiPlayer.ea.Agent(linkState, timer, new SimpleRMHC(nResamples), idPlayer2, nEvals);
// player1 = new controllers.multiPlayer.smlrand.Agent();
// player1 = new controllers.multiPlayer.smlrand.Agent();
// player2 = new controllers.multiPlayer.doNothing.Agent(linkState.copy(), timer, 1);
runner.setPlayers(player1, player2);
int nGames = 100;
runner.playGames(nGames);
System.out.println(runner.scores);
}
Aggregations