All pastes #611093 Raw Edit

iturk

public java v1 · immutable
·published 2007-07-09 19:33 UTC
rendered paste body
public class AlfaBetaWhite{    private int minimax(State state, int depth) {    	    	if (depth==0 || state.isTerminal() == true) {    		return state.eval(true);    	}    	    	int m = Integer.MIN_VALUE;    	List <State> pos = state.generate();    	for(State e: pos) {    		m = Math.max(m, -minimax(e, depth-1));    	}    	return m;    }    public State selectMove(State state, int depth) {		maxvalue = Integer.MIN_VALUE;		List <State> pos = state.generate();				// Store max value		for(State s: pos) {			s.setEval(minimax(s, depth));			if(s.getEval() > maxvalue)				maxvalue = s.getEval();		}						// Find max value                State newBoard = null;		for(State s: pos)		if(s.getEval() == maxvalue) {			newBoard = s;			break;		}				return newBoard;    }}