# Reveal all positions around this, if they are not mines either. X, y = random.randint(0, self.b_size - 1), random.randint(0, self.b_size - 1) Python def _reset_add_starting_marker(self): Try and solve this yourself by postponing the calculation!
But it means we can't allow the user to choose their initial move - we can explain this away as the "initial exploration around the rocket" and make it sound completely sensible.
Pre-calculating the adjacent counts here helps simplify the reveal logic later. We count the number of these that is a mine is_mine = True and store. The custom function get_surrounding simply returns those positions around a given x and y location. With mines in position, we can now calculate the 'adjacency' numberįor each position - simply the number of mines in the immediate vicinity, using a 3x3 grid around the given point. Self.end_game_n = (self.b_size * self.b_size) - (self.n_mines + 1) X, y = random.randint(0, self.b_size-1), random.randint(0, self.b_size-1)