My Game of Fifteen seems to work when I try to move in the four basic cardinal directions, but when I use check50, the game seems to brake in unexpected places (such as after several moves). For example, one of the requirements on check50 was to move up-up-left-down-down-left-up-up-right-down-down-right.
I manually followed the instructions until I got to the first up of the up-up-right. When I entered 5, I got:
8 4 7
_ 1 6
_ 2 3
instead of:
8 4 7
_ 1 6
5 2 3
Another example is the check50 requirement of move blank up (tile 3), then try tile 2. Using a 3x3 board, I tried to move 3:
8 7 6
5 4 _
2 1 3
then 2:
8 7 6
5 4 _
_ 1 3
Why did the 2 become an underscore? From my code, 2 is supposed if it's next to a blank tile. I believe that this issue is caused by the code thinking that 2 is next to a blank tile (ignoring the end of the row), but I added y+1 <= d-1
and such to make sure that my code doesn't go out of bounds.
Here's my code: http://pastebin.com/zsN1h6aa