public Constraint[] updateAndRemoveKnownVariables(Map map) {
	// first check for previously known values
	for (int i=nvariables-1; i>=0; --i) {
	    int s = variables[i].getState();
	    if (s>=0)
		// clear (remove variable)
		variables[i]=variables[--nvariables];
	    else if (s==BoardPosition.MARKED) {
		// marked (remove variable and decrement constant)
		variables[i]=variables[--nvariables];
		--constant;
	    }
	}
	
	// if no variables left, return
	if (nvariables<=0)
	    return null;

	// check for all clear or all marked
	Constraint[] result;
	if (constant==0) {
	    // all variables are 0 (no mines)
	    result = new Constraint[nvariables];
	    for (int i=0; i<nvariables; ++i) {
		variables[i].probe(map);
		result[i] = variables[i].newConstraint();
	    }
	}
	else if (constant==nvariables) {
	    // all variables are 1 (are mines)
	    result = new Constraint[0];
	    for (int i=0; i<nvariables; ++i)
		variables[i].mark(map);
	}
	else 
	    return null;

	// empty constraint
	nvariables=0;
	constant=0;
	return result;
    }