diff --git a/Aufg6/MineSweeper.cpp b/Aufg6/MineSweeper.cpp index aa84d24..4ae7ce3 100644 --- a/Aufg6/MineSweeper.cpp +++ b/Aufg6/MineSweeper.cpp @@ -18,14 +18,19 @@ struct MineSweeperBoard { } void spreadBombs() { while (bombCounter < 99) { - field[getRandomNumberInRange(0,15)][getRandomNumberInRange(0,15)] = "x"; - bombCounter++; + short x = getRandomNumberInRange(0,15); + short y = getRandomNumberInRange(0,15); + if (field[x][y] != "x") { + field[x][y] = "x"; + bombCounter++; + } } } std::string countNeighbourBombs(int i, int j) { i--; j--; - int counter; + int counter = 0; + // int counter; // Not setting this nerd to 0 can cause a bug for (int k = 0; k < 3; k++) { for (int l = 0; l < 3; l++) { if ((i+k < 16) && (j+l < 16) && (i-l >= 0) && (j-l >= 0)) {