All pastes #80756 Raw Edit

Anonymous

public java v1 · immutable
·published 2006-07-06 19:57 UTC
rendered paste body
public class ForcedFieldConstraintSolver implements ConstraintSolver {	public boolean solveConstraints(State s) throws NotSolvableException {		// iteratre over the structures		for (Structure structType : Structure.values()) {			for (int structId = 0; structId < NUMBERS; structId++) {				// iterate over the possible numbers				for (int i = 1; i < NUMBERS + 1; i++) {					for (int pos = 0; pos < NUMBERS; pos++) {						int lastPossiblePosition = -1;						int foundCount = 0;						if (s.isPossibleAt(structType, structId, pos, i)) {							lastPossiblePosition = i;							foundCount++;						}						if (foundCount == 1) {							s.setValue(structType, structId,									lastPossiblePosition, i);							return true;						}					}				}			}		}		return false;	}	static final int NUMBERS = 9;}