Hi there im trying to create a Minimax player in AI for dots and boxes Following this algorithm
Max-Value(state) returns a utility value
if Terminal-Test(state) then return Utility(state)
v ← MinimalGameValue
for s in Successors(state) do
v ← Max(v, MinValue(s))
return v

Min-Value(state) returns a utility value
if Terminal-Test(state) then return Utility(state)
v ← MaximalGameValue
for s in Successors(state) do
v ← Min(v, Max-Value(s))
return v

But i just seem to make any headway on,Any Help would be great

don't really know what you mean by 'dots and boxes' but it seems you have a pretty explanatory pseudo code there. what is it you are having difficulties with?

Dots and Boxes is the game where each opponent draws a line and tries to create a box with it,Here is the code i have so far, i just dont think it follows the pseudocode correctly

public class MiniMax extends AbstractPlayer {


    private int depth;
    private int INF;
    private boolean isPlayer1;

    @Override
    public Line makeMove(GameState gs){

        List<Line> lines = gs.getRemainingLines();

        return minimaxDecision(gs);

    }







      private int minimaxDecision(GameState gs) {
          List<Line> lines = gs.getRemainingLines();
          int minMaxv;
          int value;
            this.isPlayer1 = (gs.getPlayer() == 1);
            for (Line line : lines){
                GameState clone = gs.clone();
                value = clone.addLine(line);
                if(value  == 0 ){
                    minMaxv = minValue(-1,clone);
                }else{
                    minMaxv = maxValue(-1,clone);
                }

            }
            return evaluate(gs);
        }








    private int maxValue(int k, GameState state) {
            List<Line> lines = state.getRemainingLines();
            if(k == depth || lines.isEmpty()){
                return state.getValue()*((this.isPlayer1)?1:-1);
            }
            int max = -INF, value;
            for(Line line : lines){
                GameState clone = state.clone();
                value = clone.addLine(line);
                if(value < 1){
                    max = Math.max(max, minValue(k+1, clone));
                }else{
                    max = Math.max(max, maxValue(k+1, clone));
                }
            }
            return max;
        }

      private int minValue(int k,GameState state) {
            List<Line> lines = state.getRemainingLines();
            if(k == depth || lines.isEmpty()){
                return state.getValue()*((this.isPlayer1)?1:-1);
            }
            int min = INF, value;
            for(Line line : lines){
                GameState clone = state.clone();
                value = clone.addLine(line);
                if(value < 1){
                    min = Math.min(min, maxValue(k+1, clone));
                }else{
                    min = Math.min(min, minValue(k+1, clone));
                }
            }
            return min;
        }
This question has already been answered. Start a new discussion instead.