Пример #1
0
 private PuzzleArea(PuzzleBoard board)
 {
     Board          = board;
     EmptyCount     = 0;
     FilledCount    = 0;
     UndefinedCount = 0;
     Positions      = new List <Point>();
 }
Пример #2
0
        static public List <Point> GetNeigbours(PuzzleBoard board, Point center)
        {
            List <Point> result = new List <Point>();

            for (int y = -2; y < 3; y++)
            {
                for (int x = -2; x < 3; x++)
                {
                    if (y == 0 && x == 0)
                    {
                        continue;
                    }
                    Point pos = new Point(center.X + x, center.Y + y);
                    if (board.GetValue(pos) < 0 || board.GetValue(pos) > 9)
                    {
                        continue;
                    }
                    result.Add(pos);
                }
            }
            return(result);
        }
Пример #3
0
 public PuzzleArea(PuzzleBoard board, Point center) : this(board)
 {
     for (int y = -1; y < 2; y++)
     {
         int posY = center.Y + y;
         if (posY < 0 || posY >= board.Rows)
         {
             continue;
         }
         for (int x = -1; x < 2; x++)
         {
             int posX = center.X + x;
             if (posX < 0 || posX >= board.Columns)
             {
                 continue;
             }
             AddPosition(new Point(posX, posY));
         }
     }
     int value = board.GetValue(center);
     if (value < 0 || value > 9)
     {
         MaxFilled = 9 - EmptyCount;
         MinFilled = FilledCount;
         MaxEmpty  = 9 - FilledCount;
         MinEmpty  = EmptyCount;
     }
     else
     {
         _involvedNumberPositions.Add(center);
         MaxFilled = value;
         MinFilled = MaxFilled;
         MaxEmpty  = Positions.Count - value;
         MinEmpty  = MaxEmpty;
     }
     RefreshDistincts();
 }