Your problem appears to be with this piece of code:
Code:
while (check_position(i) == 0)
{
this.values_right[i] = (this.values_right[i] + 1) % 10;
}
This loop will keep going as long as check_position(i) equals 0. And the statement in the loop obviously tries one value at a time. To see which one is correct. The problem is that in a regular sudoku, unless it's retarded kid level, most positions won't have enough information to determine the number that is supposed to go into that position. In that case your script will think that all values are wrong, and your loop will go on forever. Not to mention the fact that you're looping through one value too much, the 0 value.
Try something like this:
Code:
private int[] posible_values = new int[10] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 };
...
int j;
if(this.values_right[i] == 0){
for (j = 0; j < 10; j++)
{
this.values_right[i] = posible_values[j];
if(check_position(i) != 0)
break;
}
}
This code goes through the values 1-9, or until check_position(i) returns something but 0. Notice that I expanded posible_values array to fit a last value of zero (which is what you use to represent an empty box, no?) to reset that square in case all 9 values fail. The if checks that the box isn't currently filled in.
Then you'd have to iterate through the 81 squares until you find a solution, or until the algorithm fails. (Which is when no new correct numbers were filled in during when looping through the 81 numbers)
But even then your algorithm will only be able to solve very simple sudoku.