예제 #1
0
파일: GridState.cs 프로젝트: jussik/Sudoku
 public string ToJsonDiff(GridState previous)
 {
     return string.Format("[{0}{1}]", jsonString(Description),
          string.Join("", Cells.Select((c,i) => c.ToJsonDiff(previous.Cells[i], i))
              .Where(s => s != null)
              .Select(s => "," + s))
     );
 }
예제 #2
0
파일: GridState.cs 프로젝트: jussik/Sudoku
 public bool HasChanged(GridState previous)
 {
     for (var i=0; i<81; i++) {
         if(Cells[i].Value != previous.Cells[i].Value || !Cells[i].Possibilities.SetEquals(previous.Cells[i].Possibilities))
             return true;
     }
     return false;
 }
예제 #3
0
파일: Grid.cs 프로젝트: jussik/Sudoku
 /// <summary>
 /// Loads the grid from an existing <see cref="GridState"/>.
 /// </summary>
 public void LoadState(GridState state)
 {
     for(var i=0;i<81;i++) {
         Cells[i].LoadState(state.Cells[i]);
     }
 }
예제 #4
0
파일: Grid.cs 프로젝트: jussik/Sudoku
        /// <summary>
        /// Saves the current grid into a <see cref="GridState"/> using a particular description.
        /// </summary>
        public GridState SaveState(string description)
        {
            GridState state = new GridState
            {
                Description = description,
                Cells = new CellState[81]
            };

            for (var i=0; i<81; i++) {
                state.Cells[i] = Cells[i].SaveState();
            }

            return state;
        }
예제 #5
0
 public void Add(GridState state)
 {
     States.Add(state);
 }