Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public override double ComputeHeuristicGrade() {
- double heuristic = 0.0;
- // Sprawdzenie wiersza
- for (int i = 0; i < 9; i++) {
- if (i == y)
- continue;
- if (table[x, i] == 0.0)
- heuristic++;
- else if (table[x, i] == newValue)
- return Double.PositiveInfinity;
- }
- // Sprawdzenie kolumny
- for (int i = 0; i < 9; i++) {
- if (i == x)
- continue;
- if (table[i, y] == 0.0)
- heuristic++;
- else if (table[i, y] == newValue)
- return Double.PositiveInfinity;
- }
- // Sprawdzanie kwadracika
- int r = x - (x % 3);
- int c = y - (y % 3);
- Console.WriteLine("r = {0}, c = {1}", r, c);
- for (int i = r; i < (r + 3); i++) {
- for (int j = c; j < (c + 3); j++) {
- if ((i == x) && (j == y))
- continue;
- if (table[i, j] == 0.0)
- heuristic++;
- else if (table[i, j] == newValue)
- return Double.PositiveInfinity;
- }
- }
- Console.WriteLine("Returnuje!");
- return heuristic;
- }
Advertisement
Add Comment
Please, Sign In to add comment