daily pastebin goal
63%
SHARE
TWEET

Untitled

a guest Jul 13th, 2018 64 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public Move chooseMove(Game game) {
  2.  
  3.         State s = game.getCurrentState();
  4.         List<Move> legalMoves = game.getLegalPacManMoves(); // find out what moves
  5.         // PacMan can make
  6.         double maxScore = -1000.0;
  7.         double minScore = 0.0;
  8.         Move maxMove = new Move();
  9.  
  10.         for (Move m : legalMoves) {
  11.             List<List<Move>> ghostMoves = game.getLegalCombinedGhostMoves();
  12.             for (List n : ghostMoves) {
  13.                 State next = getNextState(s, m, n);
  14.                 double stateScore = evaluateState(s, next);
  15.                 double turnaroundPenalty = (lastMove == m.getOpposite() ? -10.0 : 0.0); // penalize a move that turns around
  16.                 stateScore += turnaroundPenalty;
  17.                 if (stateScore < minScore) {
  18.                     minScore = stateScore;
  19.                 }
  20.             }
  21.             if (minScore > maxScore) {
  22.                 maxScore = minScore;
  23.                 maxMove = m;
  24.             }
  25.         }
  26.         lastMove = maxMove; // remember what move we made for next time
  27.         return maxMove;
  28.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top