Skip to main content
1 vote
Accepted

PSET3: Every move is ilegal, no matter what

After making a swap, remember to return true. return 0; is same as return false;, so your function never returns something else. Don't swap the tile_row and blank_row variables. Those have no meaning ...
Blauelf's user avatar
  • 21k
1 vote
Accepted

PSET3 'Illegal Move" coming up for legal moves as well! Almost done!

The initial position of blank tile is board[d-1][d-1], not board[d][d]. Other issues: When checking tiles around the blank one, you go outside of the board borders, if the blank tile touches the ...
obesman's user avatar
  • 1,139
1 vote
Accepted

Pset3 (Game of Fifteen): The tiles won't swap... ("Illegal move")

You use 0-based indexing (the C standard) in some places (move, won), but 1-based indexing in others (init, draw). You use a strange variable blank. This variable is initially of undefined value (...
Blauelf's user avatar
  • 21k
1 vote

Every move I do in CS50: pset3 is illegal...does anyone know why?

There are about 3 major issues in the code. First, the closing curly brace of the outer for loop is in the wrong place. It follows the actual swap code, so the earlier code that locates the blank and ...
Cliff B's user avatar
  • 69k
1 vote

PSET 3 - Fifteen - Move Function Not Working - Brain melted and not sure how to proceed. Please help

I believe that your problem lies in how you are assigning tileloc. When you say tileloc = board[i][j], what you are really doing is taking whatever value is in that index of the array and assigning ...
Steven C. Eisemann's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible