Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- campo = [[0 for i in range(9)]for j in range(9)]
- bombas = 9
- while bombas != 0:
- linha = random.randint(0,8)
- col = random.randint(0,8)
- if campo[linha][col] != 9:
- campo[linha][col] = 9
- bombas -= 1
- i = 0
- j = 0
- while i<=8:
- while j<=8:
- if campo[i][j] == 9:
- if i-1>=0:
- if j-1>= 0:
- if campo[i-1][j-1] != 9:
- campo[i-1][j-1] = campo[i-1][j-1]+1
- if campo[i-1][j] != 9:
- campo[i-1][j] = campo[i-1][j]+1
- if j+1 <= 8:
- if campo[i-1][j+1] != 9:
- campo[i-1][j+1]=campo[i-1][j+1]+1
- if j-1>= 0:
- if campo[i][j-1] != 9:
- campo[i][j-1] =campo[i][j-1]+1
- if j+1 <= 8:
- if campo[i][j+1] != 9:
- campo[i][j+1] =campo[i][j+1]+1
- if i+1 <= 8:
- if j-1>= 0:
- if campo[i+1][j-1] != 9:
- campo[i+1][j-1] = campo[i+1][j-1]+1
- if campo[i+1][j] != 9:
- campo[i+1][j] = campo[i+1][j]+1
- if j+1 <= 8:
- if campo[i+1][j+1] != 9:
- campo[i+1][j+1]=campo[i+1][j+1]+1
- j = j+1
- j = 0
- i = i+1
- print(campo)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement