I just finished trying to implement my move function. It seems to work to a certain extent, except that some of the tiles keep turning into blanks. I have the following code for my swapping:
for (int i = 0; i < d; i++)
{
for (int j = 0; j < d; j++)
{
if (board[i][j] == tile)
{
if (board[i][j+1] == 0)
{
board[i][j+1] = tile;
board[i][j] = 0;
return true;
}
I couldn't figure out how to store the position of the blank, but this should work too, right?