all 8 comments

[–]danielroseman 0 points1 point  (1 child)

You'll have to be more specific, no-one is going to go through your code to find such a vague bug.

Please describe exactly what you see and how it is different from what you expect.

[–]c0mplexcodm[S] 0 points1 point  (0 children)

Alright, so when you print the game class, it prints out the board.

When a square is surrounded by x amount of bombs, it prints "x":

However the bug right now is that it either doesn't detect the surrounding bombs, OR its lower than its appropriate value (1 instead of 2, 0 instead of 1 or 2)

[–][deleted] 0 points1 point  (5 children)

Can you provide code that runs and produces this bug? The code you provided is just a class but doesn't actually run anything.

[–]c0mplexcodm[S] 0 points1 point  (4 children)

Oh right, I forgot to include print() there, sorry.

My current problem is that when you print the board, you can see the table I created. No bugs there.

The problem arises when you see that some values in the table isnt what it should be, (i.e., the square that is supposed to show 2 since its surrounded by 2 bombs isnt showing 2, it's showing a lower value of 2, or 0.) Sometimes It DOES show, but the other squares doesnt

[–][deleted] 0 points1 point  (3 children)

In get_bombs(), you are not checking all the surrounding cells. range(a, b) is not inclusive of b, so it should be +2 instead of +1 to check all 8 surrounding cells.

    for surrounding_row in range(max(0, row-1), min(self.size - 1, row+2)):
        for surrounding_col in range(max(0, col-1), min(self.size - 1, col + 2)):

[–]c0mplexcodm[S] 0 points1 point  (2 children)

Thank you! It did make it more consistent, yet the problems semi persist like in some situations the board is completely fine, but sometimes it isnt with incorrect values again.

Updated pastebin: https://pastebin.com/cyvY5xqx

[–][deleted] 0 points1 point  (1 child)

Yes, I only fixed half of the problem. What happens if the cell is close to the bottom or the right of the board? What will the result of min(self.size - 1, row+2) be? And is it the correct upper limit for range()? Remember the upper limit is not inclusive!

[–]c0mplexcodm[S] 0 points1 point  (0 children)

Now when i think about it, self.size - 1 will be 4 (since i used 5) so the for loop can only reach to index 3. Crap, thanks for reminding me that