public static bool IsInclude(SudokuSolution a_stayed, SudokuSolution a_toremoved, bool a_use_includes_list) { if (Object.ReferenceEquals(a_stayed, a_toremoved)) { return(false); } if (a_use_includes_list) { if (!SudokuSolution.Includes.Any(pair => (a_toremoved.Type == pair.First()) && (a_stayed.Type == pair.Last()))) { return(false); } } if (a_stayed.Type == a_toremoved.Type) { if (!a_stayed.ColorUnits.Equals(a_toremoved.ColorUnits)) { return(false); } } return(a_stayed.Removed.Contains(a_toremoved.Removed) && a_toremoved.Stayed.Contains(a_stayed.Stayed) && !a_stayed.Removed.ContainsAny(a_toremoved.Stayed) && !a_stayed.Stayed.ContainsAny(a_toremoved.Removed)); }
internal void Apply(SudokuSolution a_solution) { a_solution.Removed.ForEach(num => m_board[num.Col, num.Row][num.Number - 1].State = SudokuNumberState.sudokucellstateImpossible); a_solution.Solved.ForEach(num => m_board[num.Col, num.Row][num.Number - 1].State = SudokuNumberState.sudokucellstateSolved); }
internal SudokuSolutionNode(SudokuBoard a_board, SudokuSolutionNodeState a_state, SudokuSolution a_solution = null) { m_state = a_state; m_board = a_board; m_board.BoardChanged += num => m_nextBoard = null; m_solution = a_solution; }
public SudokuIntermediateSolution(SudokuBoard a_before, SudokuBoard a_after, SudokuSolution a_solution) { Debug.Assert(a_before != null); m_before = a_before; m_after = a_after; m_solution = a_solution; }
private static void LoadNodesFromXML(XElement a_element, SudokuSolutionNode a_parent) { a_element.Element("solution_nodes").Elements().ForEach(child_element => { SudokuBoard board = SudokuBoard.LoadFromXML(child_element.Element("board")); SudokuSolutionNode child_node = a_parent.AddNode( board, (SudokuSolutionNodeState)Enum.Parse(typeof(SudokuSolutionNodeState), child_element.Attribute("state").Value), SudokuSolution.LoadFromXML(child_element.Element("solution"), board) ); LoadNodesFromXML(child_element, child_node); }); }
private static SudokuIntermediateSolution LoadFromXML(XElement a_element) { try { SudokuBoard before = SudokuBoard.LoadFromXML(a_element.Element("board_before")); SudokuBoard after = SudokuBoard.LoadFromXML(a_element.Element("board_after")); SudokuSolution solution = SudokuSolution.LoadFromXML(a_element.Element("solution"), before); SudokuIntermediateSolution intermediate_solution = new SudokuIntermediateSolution(before, after, solution); return(intermediate_solution); } catch { return(null); } }
public override bool Equals(object a_obj) { if (a_obj == null) { return(false); } if (ReferenceEquals(this, a_obj)) { return(true); } SudokuSolution solution = a_obj as SudokuSolution; if (solution == null) { return(false); } return((m_type == solution.m_type) && m_removed.Exact(solution.m_removed) && m_solved.Exact(solution.m_solved) && m_stayed.Exact(solution.m_stayed) && m_colorUnits.SelectMany().Exact(solution.m_colorUnits.SelectMany())); }
internal SudokuSolutionNode AddNode(SudokuBoard a_board, SudokuSolutionNodeState a_state, SudokuSolution a_solution) { return(AddNode(new SudokuSolutionNode(a_board, a_state, a_solution))); }
public static SudokuSolution Rotate(this SudokuSolution a_sol, SudokuBoard a_board) { return(new SudokuSolution(a_sol.Type, Rotate(a_sol.Removed, a_board), Rotate(a_sol.Stayed, a_board), Rotate(a_sol.Solved, a_board), from unit in a_sol.ColorUnits select Rotate(unit, a_board))); }