Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # module generating games, graphics & results
- import random
- class Game:
- board = []
- board_tmp = []
- start_board = None
- score = None
- def __init__(self, board_size):
- self.size = board_size
- # generate board
- for y in range(self.size):
- self.board.append([])
- self.board_tmp.append([])
- for y in range(self.size):
- for x in range(self.size):
- self.board[y].append(0)
- self.board_tmp[y].append(0)
- self.put_random_cells(random.randint(20, 60)/100)
- def put_random_cells(self, amt):
- for cell in range(int(self.size**2 * amt)):
- self.put_cell(random.randint(0, self.size), random.randint(0, self.size))
- self.start_board = self.board.copy()
- def display_console(self):
- print()
- for y in range(self.size):
- print(self.board[y])
- def put_cell(self, x, y):
- try:
- self.board[y][x] = 1
- except IndexError:
- pass
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement