def __init__(self, home, away): Broadcaster.__init__(self) self.match_teams = (home, away) self.finished = False self.watch = Watch() self.ball = Ball(self) self.reposition()
def __init__(self, width, height, num_mines): """ Positional arguments: width: the width of the game field. height: the height of the game field. num_mines: the number of mines in the game field. """ assert num_mines <= width * height Broadcaster.__init__(self) self.width, self.height = width, height self.num_mines = num_mines self.mines = Matrix(width, height) candidate_positions = [Point(x, y) for x in range(width) for y in range(height)] for location in random.sample(candidate_positions, num_mines): self.mines[location] = True self.cell_states = Matrix(width, height, State.covered) self.cell_state_counts = {State.covered: width * height, State.uncovered: 0, State.flagged: 0, State.unsure: 0} self.game_state = State.not_started
def __init__(self, **kargs): Broadcaster.__init__(self) self.queue = PieceQueue(kargs.get("generator", gen_bags)) # self.queue = PieceQueue(kargs.get("generator", gen_line_pieces)) self.queue.peek() self.cols = kargs.get("cols", 10) self.rows = kargs.get("rows", 22) # typically 16 to 24. 22 is recommended. self.obstructed_rows = 2 self.blocks = set() self.score = 0 self.lines_cleared = 0 self.level = 0 self.frames_since_last_drop = 0 self.frames_between_drops = self.get_frames_between_drops() self.held_piece = None self.may_hold = True self.active_piece = None self.lost = False