I get the following error on check50:
:( 3x3 board, move up-up-left-down-down-left-up-up-right-down-down-right
\ expected "4" character 3 of line 17, not "0"
I have tried this out, and the fourth instruction 'down' returns illegal move, thus my move function must be the problem, however I can't figure out the exact problem never mind trying to resolve it!
Some direction would be appreciated, many thanks
Here is my move function:
bool move(int tile)
{
// TODO
//int row = board[d - 1][d - 1];
//int col = board[d - 1][d - 1];
int temp;
for (int i = 0; i < d; i++)
{
for (int j = 0; j < d; j++)
{
if (tile == board[i][j])
{
{
if (board[i - 1][j] == 0 && i - 1 > 0)
{
temp = board[i - 1][j];
board[i - 1][j] = board[i][j];
board[i][j] = temp;
return true;
}
if (board[i + 1][j] == 0 && i + 1 < d)
{
temp = board[i + 1][j];
board[i + 1][j] = board[i][j];
board[i][j] = temp;
return true;
}
if (board[i][j - 1] == 0 && j - 1 > 0)
{
temp = board[i][j - 1];
board[i][j - 1] = board[i][j];
board[i][j] = temp;
return true;
}
if (board[i][j + 1] == 0 && j + 1 < d)
{
temp = board[i][j + 1];
board[i][j + 1] = board[i][j];
board[i][j] = temp;
return true;
}
}
}
}
}
return false;
}