Example #1
0
        public override Boolean IsValidMove(Cell cell)
        {
            if (cell.Value.HasValue)
              {
            var square = cell
              .Square
              .Where(c => !(c.Row == cell.Row && cell.Column == c.Column))
              .Where(c => c.Value.HasValue)
              .Select(c => c.Value.Value);
            var row = cell
              .RowCells
              .Where(c => !(c.Row == cell.Row && cell.Column == c.Column))
              .Where(c => c.Value.HasValue)
              .Select(c => c.Value.Value);
            var column = cell
              .ColumnCells
              .Where(c => !(c.Row == cell.Row && cell.Column == c.Column))
              .Where(c => c.Value.HasValue)
              .Select(c => c.Value.Value);

            var filled = square.Union(row).Union(column);
            return Board.AllPossibleValues.Except(filled).Contains(cell.Value.Value);
              }
              else
            return false;
        }
Example #2
0
 public override bool IsValidMove(Cell cell)
 {
     throw new NotImplementedException();
 }
Example #3
0
 // not sure if this method has to be marked abstract as base level, there cannot be any implementation
 // however making it not abstract will certain algo which do not want to take advantage of this method
 protected virtual void OnCellValueChange(Cell cell, IEnumerable<Cell> affectedCells, int? previous, int? current)
 {
 }
Example #4
0
 protected Boolean CheckBasicMoveValidation(Cell cell)
 {
     return true;
 }
Example #5
0
 public abstract Boolean IsValidMove(Cell cell);
Example #6
0
        protected override void OnCellValueChange(Cell cell, IEnumerable<Cell> affectedCells, int? previous, int? current)
        {
            //Calculate();

              if (!previous.HasValue && current.HasValue) // if the value is added
            affectedCells.ToList().ForEach(c => cube[c].AddDistinct(cell.Value.Value));
              else if (previous.HasValue && !current.HasValue) // if the value is removed
              {
            Calculate();
              }
              else if (previous.HasValue && current.HasValue && previous.Value != current.Value) // if the value is updated
              {
            Calculate();
              }
              // else // we do want any change in case previous and current values are same
        }
Example #7
0
 public IEnumerable<int> GetRemaining(Cell cell)
 {
     return Board.AllPossibleValues.Except(cube[cell]);
 }
Example #8
0
 public IEnumerable<int> GetFilled(Cell cell)
 {
     return cube[cell].AsEnumerable<int>();
 }