private bool TryDecision(Board board, BinaryDecision decision, Difficulty cap) { Board trueDecision = board.Clone(); Board falseDecision = board.Clone(); decision.Decide(trueDecision, true); decision.Decide(falseDecision, false); trueDecision.solution = trueDecision.Solve(cap); falseDecision.solution = falseDecision.Solve(cap); trueDecision.Finish(); falseDecision.Finish(); BoardDifference trueDifference = new BoardDifference(board, trueDecision); BoardDifference falseDifference = new BoardDifference(board, falseDecision); BoardDifference merged = BoardDifference.Merge(trueDifference, falseDifference); if (merged.HasDifferences()) { merged.Apply(board); return(true); } else { return(false); } }
public static BoardDifference Merge(BoardDifference first, BoardDifference second) { BoardDifference merged = new BoardDifference(); for (int k = 0; k < Board.size * Board.size; k++) { RemovedNotes mergedNotes = merged.removedNotes[k]; RemovedNotes firstNotes = first.removedNotes[k]; RemovedNotes secondNotes = second.removedNotes[k]; for (int n = 0; n < CellInfo.numbers; n++) { if (firstNotes.Removed[n] && secondNotes.Removed[n]) { mergedNotes.Remove(n); } } } return(merged); }