Skip to content

Commit

Permalink
more skeletal
Browse files Browse the repository at this point in the history
  • Loading branch information
aeblyve committed Nov 14, 2021
1 parent d769a4a commit 285fd66
Showing 1 changed file with 49 additions and 10 deletions.
59 changes: 49 additions & 10 deletions code/bot/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,27 @@
import random
import typing

class TetrisGame():
"""Our search-problem class"""

def __init__(self):
pass

def add_piece(self):
"""Add a specific piece to the game"""
pass

def next_piece(self):
pass

def is_terminal(self, state: 'TetrisState'):
"""Can be re-implemented based on subclass of game"""
# Default: there exists a block greater than the "roof"
pass

def get_succs(self):
pass

class TetrisState():
"""Tetris states are all the same really
- it's a driver TetrisGame that differentiates gametypes
Expand All @@ -13,10 +34,19 @@ def __init__(self, block_grid: 'BlockGrid', piece: 'Piece'):
self.current_piece = piece

class Piece():
"""A collection of blocks"""
pass
"""A collection of blocks- limited to 5x5
Pieces rotate about the geometric center at (2, 2) - sculpt accordingly
"""

def __init__(self, block_label: str, block_coordinates: list):
self.piece_grid = []
for i in range(5):
self.piece_grid.append([Block("empty")] * 5)
for x, y in block_coordinates:
self.piece_grid[x][y] = Block(block_label)

def left_rotate(self):
pass

class Block():
def __init__(self, label):
Expand All @@ -28,22 +58,31 @@ def __repr__(self):
else:
return "x"

def __eq__(self, o):
return self.label == o.label


class BlockGrid():

def __init__(self, x_dimension=10, y_dimension=20, cheese_count=0):
if cheese_count > y_dimension:
raise RuntimeError
def __init__(self, x_dimension=10, y_dimension=20):
self.grid = []
self.x_dimension = x_dimension
self.y_dimension = y_dimension

for y in range(y_dimension):
self.grid.append([Block("empty")] * x_dimension)

for cheese_y in range(cheese_count):
cheese_row = [Block("cheese")] * x_dimension
hole_index = random.choice(range(x_dimension))
cheese_row[hole_index] = Block("empty")
self.grid[y_dimension - cheese_y - 1] = cheese_row
def send_garbage(self, garbage_count: int, garbage_label: str, hole_count: int):
if hole_count > self.x_dimension:
raise RuntimeError
for garbage_y in range(garbage_count):
garbage_row = [Block(garbage_label)] * self.x_dimension
while hole_count != 0:
new_hole_index = random.choice(range(self.x_dimension))
if garbage_row[new_hole_index] != Block("empty"):
garbage_row[new_hole_index] = Block("empty")
hole_count -= 1
self.grid[self.y_dimension - garbage_y -1] = garbage_row

def __repr__(self):
repr = ""
Expand Down

0 comments on commit 285fd66

Please sign in to comment.