I want to implement PacMan game with minimax algorithm but I do not understand the meaning of algorithm fluently. I have written this code
public MOVE miniMax(Game game,Node[] nodes,int depth,Boolean pacMan){
int value;
MOVE thisMove;
int bestValue;
int score=0;
EnumMap<MOVE, MOVE[]> possibleMoves = nodes[game.getPacmanCurrentNodeIndex()].allPossibleMoves;
MOVE[] moves = possibleMoves.get(MOVE.NEUTRAL);
if(depth == 0)
score = evaluationFunction(game);
if(pacMan){
bestValue = -INF;
for(int i=0;i<moves.length;i++){
game.copy();
game.updatePacMan(moves[i]);
thisMove= miniMax(game,nodes,depth-1,Boolean.FALSE);
//bestValue = Math.max(bestValue, value);
}
return thisMove;
}else{
bestValue = INF;
for(int i=0;i<moves.length;i++){
game.copy();
game.updatePacMan(moves[i]);
thisMove= miniMax(game,nodes,depth-1,Boolean.TRUE);
//bestValue = Math.min(bestValue, value);
}
//return bestValue;
return thisMove;
}
}
public int evaluationFunction(Game game){
return 0;
}
I have written this code considering the Wikipedia pseudo code but I have a problem that I do not know how can I calculate evaluation function as an integer and then decide to return a move,I should only return a move. And Is Evaluation function calculate for one move or choose one between all possible move for a node?