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; }
public override bool IsValidMove(Cell cell) { throw new NotImplementedException(); }
// 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) { }
protected Boolean CheckBasicMoveValidation(Cell cell) { return true; }
public abstract Boolean IsValidMove(Cell cell);
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 }
public IEnumerable<int> GetRemaining(Cell cell) { return Board.AllPossibleValues.Except(cube[cell]); }
public IEnumerable<int> GetFilled(Cell cell) { return cube[cell].AsEnumerable<int>(); }