Ejemplo n.º 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))
     );
 }
Ejemplo n.º 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;
 }
Ejemplo n.º 3
0
 /// <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]);
     }
 }
Ejemplo n.º 4
0
        /// <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;
        }
Ejemplo n.º 5
0
 public void Add(GridState state)
 {
     States.Add(state);
 }