guys! I am a beginner and not good enough at programming yet. On the game of fifteen I am trying to understand how this block of code works for a long time and still cant get the idea!:(
bool legalmove(void) { // check if on top row. If so check up for 0 if (tile_i > 0 && board[tile_i - 1][tile_j] == 0) return true; // bottom if (tile_i < d-1 && board[tile_i + 1][tile_j] == 0) return true; // left if (tile_j > 0 && board[tile_i][tile_j - 1] == 0) return true; // right if (tile_j < d-1 && board[tile_i][tile_j + 1] == 0) return true; else return false; }
I understand it in general but I can`t get the details...