added square
This commit is contained in:
parent
e84a27e1ac
commit
546fd0dee7
2 changed files with 52 additions and 0 deletions
6
sources/Grid.py
Normal file
6
sources/Grid.py
Normal file
|
@ -0,0 +1,6 @@
|
|||
__author__ = 'gaugendre'
|
||||
|
||||
|
||||
class Grid:
|
||||
def __init__(self):
|
||||
pass
|
46
sources/Square.py
Normal file
46
sources/Square.py
Normal file
|
@ -0,0 +1,46 @@
|
|||
__author__ = 'gaugendre'
|
||||
|
||||
|
||||
class Square:
|
||||
"""
|
||||
Represents a square in the grid.
|
||||
A square can be either Red, Blue, or Nothing, depending on the text
|
||||
written in it and displayed ('R', 'B' or ' ').
|
||||
"""
|
||||
|
||||
def __init__(self, horiz, vert):
|
||||
self.horiz = horiz
|
||||
self.vert = vert
|
||||
|
||||
def get_next_horiz(self):
|
||||
return Square(self.horiz + 1, self.vert)
|
||||
|
||||
def get_prev_horiz(self):
|
||||
return Square(self.horiz - 1, self.vert)
|
||||
|
||||
def get_next_vert(self):
|
||||
return Square(self.horiz, self.vert + 1)
|
||||
|
||||
def get_prev_vert(self):
|
||||
return Square(self.horiz, self.vert - 1)
|
||||
|
||||
def __eq__(self, other):
|
||||
if other is None or not isinstance(other, Square):
|
||||
return False
|
||||
else:
|
||||
return self.vert == other.vert and self.horiz == other.horiz
|
||||
|
||||
def __hash__(self):
|
||||
return hash((self.horiz, self.vert))
|
||||
|
||||
|
||||
def solve(grid):
|
||||
for char in grid:
|
||||
pass
|
||||
|
||||
|
||||
grid = [['R', ' ', ' ', 'R'],
|
||||
['R', ' ', 'B', ' '],
|
||||
[' ', 'R', ' ', ' '],
|
||||
[' ', ' ', ' ', ' ']]
|
||||
|
Loading…
Reference in a new issue