public double evaluate(Tree<Board> tree, boolean maxPlayer) {
		Board b = tree.getRoot();
		if (tree.getLeaves().isEmpty()) {
			this.isFinished = true;
			return getBoardValue(b);
		} else {
			double bestValue;
			if (maxPlayer) {
				bestValue = Integer.MIN_VALUE;
				List<Tree<Board>> t = tree.getLeaves();
				for(int i = 0; i < t.size(); i++) {
					double value = evaluate(t.get(i), false);
					bestValue = bestValue > value ? bestValue : value;
				}
			} else {
				bestValue = Integer.MAX_VALUE;
				List<Tree<Board>> t = tree.getLeaves();
				for(int i = 0; i < t.size(); i++) {
					double value = evaluate(t.get(i), true);
					bestValue = bestValue < value ? bestValue : value; 
				}
			}
			tree.setScore(bestValue);
			this.isFinished = true;
			return bestValue;
		}
	}