Skip to content

Instantly share code, notes, and snippets.

@sampottinger
Created November 12, 2012 04:39
Show Gist options
  • Save sampottinger/4057552 to your computer and use it in GitHub Desktop.
Save sampottinger/4057552 to your computer and use it in GitHub Desktop.
Cell
import Queue as queue
NORTH = 0
EAST = 1
SOUTH = 2
WEST = 3
class Cell:
#Walls are defined clockwise, [N,E,S,W], with 1 being a wall and 0 the lack of
def __init__(self, location):
self.location = location
self.borders = [1,1,1,1]
self.walls = [1,1,1,1]
def get_location(self):
return self.location
def has_border(self, direction):
self.__check_direction(direction)
return self.borders[direction]
def has_wall(self, direction):
self.__check_direction(direction)
return self.walls[direction]
def set_border(self, direction, value):
self.__check_direction(direction)
self.borders[direction] = value
def set_wall(self, direction, value):
self.__check_direction(direction)
self.walls[direction] = value
def __check_direction(self, direction):
if direction > WEST or direction < NORTH:
raise ValueError("Invalid direction.")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment