pacman.test.ForwardModelTest Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of pacman-main Show documentation
Show all versions of pacman-main Show documentation
The main code for Ms. Pac-Man Vs Ghosts
package pacman.test;
import pacman.game.Game;
import pacman.game.comms.BasicMessenger;
import pacman.game.info.GameInfo;
import pacman.game.internal.Ghost;
import pacman.game.internal.PacMan;
import java.util.EnumMap;
import static pacman.game.Constants.GHOST;
import static pacman.game.Constants.MOVE;
/**
* Created by pwillic on 09/05/2016.
*/
public class ForwardModelTest {
public static void main(String[] args) {
Game game = new Game(System.currentTimeMillis(), new BasicMessenger(0, 1, 1));
game.copy(new PacMan(game.getPacmanCurrentNodeIndex(), MOVE.DOWN, 2, true));
GameInfo info = game.getBlankGameInfo();
// Just forward the game itself
info.setPacman(new PacMan(game.getPacmanCurrentNodeIndex(), MOVE.DOWN, game.getPacmanNumberOfLivesRemaining(), true));
info.setGhost(GHOST.INKY, new Ghost(GHOST.INKY, 10, 0, 0, MOVE.NEUTRAL));
// info.fixGhosts((x) -> new Ghost(x, 10, 0, 0, MOVE.NEUTRAL));
Game next = game.getGameFromInfo(info);
for (int i = 0; i < 100; i++) {
EnumMap inkyMove = new EnumMap<>(GHOST.class);
inkyMove.put(GHOST.INKY, MOVE.LEFT);
next.advanceGame(MOVE.DOWN, inkyMove);
System.out.println(next.getGhostCurrentNodeIndex(GHOST.INKY));
}
System.out.println("Finished");
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy