Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- class Mine:
- def __init__(self, difficulty):
- self.difficulty = difficulty
- self.n = 0
- self.counter = 0
- self.board = []
- self.serious_dict = {
- "Easy": [10, 5],
- "Normal": [20, 10],
- "Hard": [30, 15]
- }
- def are_you_serious(self):
- if self.difficulty == "Easy":
- self.n = self.serious_dict["Easy"][0]
- self.counter = self.serious_dict["Easy"][1]
- elif self.difficulty == "Normal":
- self.n = self.serious_dict["Normal"][0]
- self.counter = self.serious_dict["Normal"][1]
- elif self.difficulty == "Hard":
- self.n = self.serious_dict["Hard"][0]
- self.counter = self.serious_dict["Hard"][1]
- def game_matrix(self):
- symbols = ["-", "*"]
- for i in range(self.n):
- result = random.choices(symbols, weights=[50, 25], k=self.n)
- self.board.append(result)
- for j in self.board:
- print(f"{' '.join(j)}")
- def player_move(self):
- while True:
- if self.counter == 0:
- print("You passed the mine field!")
- print("You win. GG!")
- break
- print(f"Enter the first number between 0 to {self.n - 1} including: ", end="")
- coordinate_x = int(input())
- while True:
- if 0 <= coordinate_x <= (self.n - 1):
- break
- else:
- print("Wrong input!")
- print(f"Enter enter the first number between 0 to {self.n - 1} including: ", end="")
- coordinate_x = int(input())
- print(f"Enter the second number between 0 to {self.n - 1} including: ", end="")
- coordinate_y = int(input())
- while True:
- if 0 <= coordinate_y <= (self.n - 1):
- break
- else:
- print("Wrong input!")
- print(f"Enter the second number between 0 to {self.n - 1} including: ", end="")
- coordinate_y = int(input())
- move = self.board[coordinate_x][coordinate_y]
- if move == "-":
- self.counter -= 1
- print("You survive!")
- elif move == "*":
- print("You hug a mine.")
- print("Game Over!")
- break
- obj = Mine(difficulty=input("Choose between Easy, Normal or Hard: "))
- obj.are_you_serious()
- obj.game_matrix()
- obj.player_move()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement