Can someone please tell me if my "won" logic will work? Will loop through each tile making sure first tile is 1, second tile is 2, etc. If a tile is not the expected number, return false(not sure if this is right) and continue playing the game. If loop is able to finish, i'm not sure how to make a function that says if the loop makes it to the end without returning false, you win. So my thought here was to finish the loop, check the first tile(because it has to be 1 in order for you to get to that check point) for victory. Thanks in advance.
/**
* Returns true if game is won (i.e., board is in winning configuration),
* else false.
*/
bool won(void)
{
// TODO
return false;
int x = 1;
do
// 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)
{
continue;
x++;
}
else{
return false;}
}
}
}
while (x < d+1);
//if loop is able to finish, check the first tile and declare victory//
if (board[0][0] == 1)
{
return true;
}
}