Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public Move chooseMove(Game game) {
- State s = game.getCurrentState();
- List<Move> legalMoves = game.getLegalPacManMoves(); // find out what moves
- // PacMan can make
- double maxScore = -1000.0;
- double minScore = 0.0;
- Move maxMove = new Move();
- for (Move m : legalMoves) {
- List<List<Move>> ghostMoves = game.getLegalCombinedGhostMoves();
- for (List n : ghostMoves) {
- State next = getNextState(s, m, n);
- double stateScore = evaluateState(s, next);
- double turnaroundPenalty = (lastMove == m.getOpposite() ? -10.0 : 0.0); // penalize a move that turns around
- stateScore += turnaroundPenalty;
- if (stateScore < minScore) {
- minScore = stateScore;
- }
- }
- if (minScore > maxScore) {
- maxScore = minScore;
- maxMove = m;
- }
- }
- lastMove = maxMove; // remember what move we made for next time
- return maxMove;
- }
Add Comment
Please, Sign In to add comment