示例#1
0
 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
 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);
 }