0

Stuck on WON where the check is failing on the winning prompts. I can't really use GDB and debug WON without actually trying to beat the game, but i don't think my logic is wrong in this code. Have a feeling it's more of an error with my return placements than anything else. gist of my code is the last tile must be blank(0) in order to proceed.

/**
 * Returns true if game is won (i.e., board is in winning configuration), 
 * else false.
 */
bool won(void)
{



{   
int x = 1;
// go through each tile from 1 to d-1//

   {

for (int row = 0; row < d; row++)
    {
       for (int column = 0; column < d; column++)
            {
                if(board[row][column] == x && board[d-1][d-1] == 0)
                    {
                    x++;
                    }

                else{
                    return false;}
            }


    }


}

} 


return true;   

   }

//end of game//
0

In a win, does board[d-1][d-1] == x or 0?

If this answers your question, please click on the check mark to accept. Let's keep up on forum maintenance. ;-)

| improve this answer | |

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .