/// <summary> /// Get tripple from the field /// </summary> /// <param name="col"></param> /// <param name="row"></param> /// <param name="direction"></param> /// <returns></returns> public Tripple GetTripple(int col, int row, TrippleDirection direction) { Tripple tripple = new Tripple(); if (direction == TrippleDirection.horizontal) { if (col >= 8) { return(null); } for (int i = 0; i < 3; i++) { tripple.Examine[i] = GetCell(col + i, row); } } else { if (row >= 8) { return(null); } for (int i = 0; i < 3; i++) { tripple.Examine[i] = GetCell(col, row + i); } } return(tripple); }
/// <summary> /// Update the tripple in the field /// </summary> /// <param name="col"></param> /// <param name="row"></param> /// <param name="direction"></param> /// <param name="number"></param> /// <param name="content"></param> /// <param name="source"></param> public void SetTrippleCell(int col, int row, TrippleDirection direction, Byte number, char content, Cell.CellSource source) { Tripple tripple = GetTripple(col, row, direction); tripple.Examine[number].Content = content; tripple.Examine[number].Source = source; }
public bool CheckTripple(int col, int row, TrippleDirection direction) { Tripple tripple = GetTripple(col, row, direction); if (tripple == null) { return(false); } return(tripple.CountCellContent()); }
/// <summary> /// Check the column or row /// </summary> /// <param name="position"></param> /// <param name="direction"></param> /// <returns></returns> public bool CheckDirection(byte position, TrippleDirection direction) { bool Result = false; Cell cell = new Cell(); byte OpenPosition = 10; byte Empty = 0; byte Zero = 0; byte One = 0; for (byte i = 0; i < 10; i++) { switch (direction) { case TrippleDirection.horizontal: cell = GetCell(i, position); break; case TrippleDirection.vertical: cell = GetCell(position, i); break; default: break; } switch (cell.Content) { case '0': Zero++; break; case '1': One++; break; default: Empty++; OpenPosition = i; break; } } if (Empty == 1) { if (Zero == 4 && One == 5) { switch (direction) { case TrippleDirection.horizontal: SetCell(OpenPosition, position, '0', Cell.CellSource.rule); break; case TrippleDirection.vertical: SetCell(position, OpenPosition, '0', Cell.CellSource.rule); break; } } else if (Zero == 5 && One == 4) { switch (direction) { case TrippleDirection.horizontal: SetCell(OpenPosition, position, '1', Cell.CellSource.rule); break; case TrippleDirection.vertical: SetCell(position, OpenPosition, '1', Cell.CellSource.rule); break; } } Result = true; } return(Result); }