VEndymionV

Untitled

Mar 25th, 2018
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.43 KB | None | 0 0
  1.  public override double ComputeHeuristicGrade() {
  2.  
  3.             double heuristic = 0.0;
  4.  
  5.             // Sprawdzenie wiersza
  6.             for (int i = 0; i < 9; i++) {
  7.  
  8.                 if (i == y)
  9.                     continue;
  10.  
  11.                 if (table[x, i] == 0.0)
  12.                     heuristic++;
  13.  
  14.                 else if (table[x, i] == newValue)
  15.                     return Double.PositiveInfinity;
  16.             }
  17.  
  18.             // Sprawdzenie kolumny
  19.             for (int i = 0; i < 9; i++) {
  20.  
  21.                 if (i == x)
  22.                     continue;
  23.  
  24.                 if (table[i, y] == 0.0)
  25.                     heuristic++;
  26.  
  27.                 else if (table[i, y] == newValue)
  28.                     return Double.PositiveInfinity;
  29.             }
  30.  
  31.             // Sprawdzanie kwadracika
  32.             int r = x - (x % 3);
  33.             int c = y - (y % 3);
  34.             Console.WriteLine("r = {0}, c = {1}", r, c);
  35.            
  36.             for (int i = r; i < (r + 3); i++) {
  37.  
  38.                 for (int j = c; j < (c + 3); j++) {
  39.  
  40.                     if ((i == x) && (j == y))
  41.                         continue;
  42.  
  43.                     if (table[i, j] == 0.0)
  44.                         heuristic++;
  45.  
  46.                     else if (table[i, j] == newValue)
  47.                         return Double.PositiveInfinity;
  48.                 }
  49.             }
  50.             Console.WriteLine("Returnuje!");
  51.             return heuristic;
  52.         }
Advertisement
Add Comment
Please, Sign In to add comment