Minesweeper Recursion Issue

Hey guys, i'm working on a minesweeper project for school(due tonight unfortunately), and I've run into a problem. I use a recursive function called recurseCheck which i use to check for empty spaces around the space selected on the minesweeper grid. I think it is infinitely calling the function, and I really don't know why. Since this is due in about 3 hours if anyone could help me find any logic errors, I would really appreciate it. Thanks

This is the function
 ``123456789101112131415161718192021222324252627`` ``````void recurseCheck (int row, int col, Grid theGrid) { if (row>9 || row<0 || col>9 || col<0 || theGrid.getArrIsMine(row,col)==true || theGrid.getArrCovered(row,col)==false || theGrid.getArrFlagged(row,col)==true) return; theGrid.setArrCovered(false,row,col); theGrid.displayGrid(); if (theGrid.getArrMines(row, col)==0) { if (theGrid.getArrIsMine(row-1,col-1)==false && theGrid.getArrFlagged(row-1,col-1)==false && theGrid.getArrCovered(row-1,col-1)==true && col>0 && row>0) recurseCheck(row-1,col-1,theGrid); if (theGrid.getArrIsMine(row-1,col)==false && theGrid.getArrFlagged(row-1,col)==false && theGrid.getArrCovered(row-1,col)==true && row>0) recurseCheck(row-1,col,theGrid); if (theGrid.getArrIsMine(row-1,col+1)==false && theGrid.getArrFlagged(row-1,col+1)==false && theGrid.getArrCovered(row-1,col+1)==true && row>0 && col<9) recurseCheck(row-1,col+1,theGrid); if (theGrid.getArrIsMine(row,col-1)==false && theGrid.getArrFlagged(row,col-1)==false && theGrid.getArrCovered(row,col-1)==true && col>0) recurseCheck(row,col-1,theGrid); if (theGrid.getArrIsMine(row,col+1)==false && theGrid.getArrFlagged(row,col+1)==false && theGrid.getArrCovered(row,col+1)==true && col<9) recurseCheck(row,col+1,theGrid); if (theGrid.getArrIsMine(row+1,col-1)==false && theGrid.getArrFlagged(row+1,col-1)==false && theGrid.getArrCovered(row+1,col-1)==true && row<9 && col>0) recurseCheck(row+1,col-1,theGrid); if (theGrid.getArrIsMine(row+1,col)==false && theGrid.getArrFlagged(row+1,col)==false && theGrid.getArrCovered(row+1,col)==true && row<9) recurseCheck(row+1,col,theGrid); if (theGrid.getArrIsMine(row+1,col+1)==false && theGrid.getArrFlagged(row+1,col+1)==false && theGrid.getArrCovered(row+1,col+1)==true && row<9 && col<9) recurseCheck(row+1,col+1,theGrid); } theGrid.displayGrid(); }``````

This is the class Grid
 ``123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122`` ``````Grid() {//Checking mines for inner 9x9 grid. for (int i=1; i<9;i++) { for (int j=1; j<9; j++) { if (arr[i-1][j-1].getIsMine()==true) arr[i][j].setMines(arr[i][j].getMines()+1); if (arr[i-1][j].getIsMine()==true) arr[i][j].setMines(arr[i][j].getMines()+1); if (arr[i-1][j+1].getIsMine()==true) arr[i][j].setMines(arr[i][j].getMines()+1); if (arr[i][j-1].getIsMine()==true) arr[i][j].setMines(arr[i][j].getMines()+1); if (arr[i][j+1].getIsMine()==true) arr[i][j].setMines(arr[i][j].getMines()+1); if (arr[i+1][j-1].getIsMine()==true) arr[i][j].setMines(arr[i][j].getMines()+1); if (arr[i+1][j].getIsMine()==true) arr[i][j].setMines(arr[i][j].getMines()+1); if (arr[i+1][j+1].getIsMine()==true) arr[i][j].setMines(arr[i][j].getMines()+1); } } //Checking for mines for left-most column excluding end points. for(int i=1; i<9; i++) { if (arr[i-1][0].getIsMine()==true) arr[i][0].setMines(arr[i][0].getMines()+1); if (arr[i-1][1].getIsMine()==true) arr[i][0].setMines(arr[i][0].getMines()+1); if (arr[i][1].getIsMine()==true) arr[i][0].setMines(arr[i][0].getMines()+1); if (arr[i+1][0].getIsMine()==true) arr[i][0].setMines(arr[i][0].getMines()+1); if (arr[i+1][1].getIsMine()==true) arr[i][0].setMines(arr[i][0].getMines()+1); } //same as above but for the furthest right column. for (int i=1; i<9; i++) { if (arr[i-1][9].getIsMine()==true) arr[i][9].setMines(arr[i][9].getMines()+1); if (arr[i-1][8].getIsMine()==true) arr[i][9].setMines(arr[i][9].getMines()+1); if (arr[i][8].getIsMine()==true) arr[i][9].setMines(arr[i][9].getMines()+1); if (arr[i+1][9].getIsMine()==true) arr[i][9].setMines(arr[i][9].getMines()+1); if (arr[i+1][8].getIsMine()==true) arr[i][9].setMines(arr[i][9].getMines()+1); } //same but for first row for (int i=1; i<9; i++) { if (arr[0][i-1].getIsMine()==true) arr[0][i].setMines(arr[0][i].getMines()+1); if (arr[0][i+1].getIsMine()==true) arr[0][i].setMines(arr[0][i].getMines()+1); if (arr[1][i-1].getIsMine()==true) arr[0][i].setMines(arr[0][i].getMines()+1); if (arr[1][i].getIsMine()==true) arr[0][i].setMines(arr[0][i].getMines()+1); if (arr[1][i+1].getIsMine()==true) arr[0][i].setMines(arr[0][i].getMines()+1); } //last row for (int i=1; i<9; i++) { if (arr[9][i-1].getIsMine()==true) arr[9][i].setMines(arr[9][i].getMines()+1); if (arr[9][i+1].getIsMine()==true) arr[9][i].setMines(arr[9][i].getMines()+1); if (arr[8][i].getIsMine()==true) arr[9][i].setMines(arr[9][i].getMines()+1); if (arr[8][i-1].getIsMine()==true) arr[9][i].setMines(arr[9][i].getMines()+1); if (arr[8][i+1].getIsMine()==true) arr[9][i].setMines(arr[9][i].getMines()+1); } //Upper left corner if (arr[0][1].getIsMine()==true) arr[0][0].setMines(arr[0][0].getMines()+1); if (arr[1][1].getIsMine()==true) arr[0][0].setMines(arr[0][0].getMines()+1); if (arr[1][0].getIsMine()==true) arr[0][0].setMines(arr[0][0].getMines()+1); //Lower left corner if (arr[9][1].getIsMine()==true) arr[9][0].setMines(arr[9][0].getMines()+1); if (arr[8][1].getIsMine()==true) arr[9][0].setMines(arr[9][0].getMines()+1); if (arr[8][0].getIsMine()==true) arr[9][0].setMines(arr[9][0].getMines()+1); //upper right corner if (arr[0][8].getIsMine()==true) arr[0][9].setMines(arr[0][9].getMines()+1); if (arr[1][8].getIsMine()==true) arr[0][9].setMines(arr[0][9].getMines()+1); if (arr[1][9].getIsMine()==true) arr[0][9].setMines(arr[0][9].getMines()+1); //lower right corner if (arr[8][9].getIsMine()==true) arr[9][9].setMines(arr[9][9].getMines()+1); if (arr[8][8].getIsMine()==true) arr[9][9].setMines(arr[9][9].getMines()+1); if (arr[9][8].getIsMine()==true) arr[9][9].setMines(arr[9][9].getMines()+1); } };``````

This is the Cell class

 ``12345678910111213141516171819202122232425262728293031323334353637383940414243444546`` ``````class Cell { private: bool isMine, covered, flagged; int mines; public: bool getFlagged () { return flagged; } void setFlagged (bool flag) { flagged=flag; } int getMines() { return mines; } void setMines(int m) { mines=m; } bool getIsMine() { return isMine; } bool getCovered() { return covered; } void setCovered(bool cover) { covered=cover; } Cell() { int random=rand()%10+1; if (random==2) isMine=true; else isMine=false; mines=0; covered=true; flagged=false; } };``````
There are a lot of conditions to check through here and I would think you would have more luck debugging the program and going through where you think the problems are line by line and seeing if they give the results you expect.

The only quick guess I can give you is, in the recurseCheck function you are passing the Grid object by value and then calling functions on it. However all of those values will only be given to the local copy of the object in the function not the one you passed. You will need to pass it by reference if you want to change this.

` void recurseCheck (int row, int col, Grid &theGrid) `

(This may be part of your design how you currently have it, it's just hard to tell).
James, you're the man! I can't believe that you figured this out so fast and with such little code! Thank you so much man, I probably went from a C to and A on this project because of you.