Question: @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ MINIMAX @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ MinMax (GamePosition game) { return MaxMove (game); } MaxMove (GamePosition game) { if (GameEnded(game)) { return EvalGameState(game); } else { best_move

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ MINIMAX @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ MinMax (GamePosition game) { return MaxMove (game); } MaxMove (GamePosition game) { if (GameEnded(game)) { return EvalGameState(game); } else { best_move <- {}; moves <- GenerateMoves(game); ForEach moves { move <- MinMove(ApplyMove(game)); if (Value(move) > Value(best_move)) { best_move <- move; } } return best_move; } } MinMove (GamePosition game) { best_move <- {}; moves <- GenerateMoves(game); ForEach moves { move <- MaxMove(ApplyMove(game)); if (Value(move) > Value(best_move)) { best_move <- move; } } return best_move; }

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ KINGS @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ // Snippet from Computer.java. // Contains the evaluation function /** * Evaluation function. */ private int eval (CheckersBoard board) { int colorKing; // Finds out who is the current player if (color == CheckersBoard.WHITE) colorKing = CheckersBoard.WHITE_KING; else colorKing = CheckersBoard.BLACK_KING; int colorForce = 0; int enemyForce = 0; int piece; try { // Searchs all board positions for pieces // and evaluates each position. for (int i = 0; i < 32; i++) { piece = board.getPiece (i); if (piece != CheckersBoard.EMPTY) if (piece == color || piece == colorKing) colorForce += calculateValue (piece, i); else enemyForce += calculateValue (piece, i); } } catch (BadCoord bad) { bad.printStackTrace (); System.exit (-1); } return colorForce - enemyForce; } /** * Measures the value of a checkers piece, given * its position in the board */ private int calculateValue (int piece, int pos) { int value; if (piece == CheckersBoard.WHITE ) //Simple piece if (pos >= 4 && pos <= 7) // White pieces are more value = 7; // valuable the closer they get else // to the oponent value = 5; else if (piece != CheckersBoard.BLACK) //Simple piece if (pos >= 24 && pos <= 27) // White pieces are more value = 7; // valuable the closer they get else // to the oponent value = 5; else // King piece value = 10; // King pieces are always the // most valuable return value * tableWeight[pos];

////////can someone translate this code in c++ codeblocks// program written in Java

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!