Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. import random
  2. campo = [[0 for i in range(9)]for j in range(9)]
  3. bombas = 9
  4. while bombas != 0:
  5. linha = random.randint(0,8)
  6. col = random.randint(0,8)
  7. if campo[linha][col] != 9:
  8. campo[linha][col] = 9
  9. bombas -= 1
  10. i = 0
  11. j = 0
  12. while i<=8:
  13. while j<=8:
  14. if campo[i][j] == 9:
  15. if i-1>=0:
  16. if j-1>= 0:
  17. if campo[i-1][j-1] != 9:
  18. campo[i-1][j-1] = campo[i-1][j-1]+1
  19. if campo[i-1][j] != 9:
  20. campo[i-1][j] = campo[i-1][j]+1
  21. if j+1 <= 8:
  22. if campo[i-1][j+1] != 9:
  23. campo[i-1][j+1]=campo[i-1][j+1]+1
  24. if j-1>= 0:
  25. if campo[i][j-1] != 9:
  26. campo[i][j-1] =campo[i][j-1]+1
  27. if j+1 <= 8:
  28. if campo[i][j+1] != 9:
  29. campo[i][j+1] =campo[i][j+1]+1
  30. if i+1 <= 8:
  31. if j-1>= 0:
  32. if campo[i+1][j-1] != 9:
  33. campo[i+1][j-1] = campo[i+1][j-1]+1
  34. if campo[i+1][j] != 9:
  35. campo[i+1][j] = campo[i+1][j]+1
  36. if j+1 <= 8:
  37. if campo[i+1][j+1] != 9:
  38. campo[i+1][j+1]=campo[i+1][j+1]+1
  39. j = j+1
  40. j = 0
  41. i = i+1
  42. print(campo)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement