Created
July 19, 2013 16:10
-
-
Save robrocker7/6040372 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Board(object): | |
""" This is the base board object | |
The initialize function can be sent a board_size attribute which defaults | |
to 5x5 | |
""" | |
board = [] | |
board_size = None | |
tile_character = '0' | |
def _generate_board(self): | |
# y = Y AXIS | |
# x = X AXIS | |
for y in range(1, self.board_size+1): | |
row = [] | |
for x in range(1, self.board_size+1): | |
row.append(self.tile_character) | |
self.board.append(row) | |
def render_board(self): | |
counter = 1 | |
for yaxis in self.board: | |
print '{0} - {1}'.format(counter, ', '.join(yaxis)) | |
counter += 1 | |
print ' {0}'.format( | |
' '.join([str(i) for i in range(1, self.board_size+1)])) | |
def __init__(self, board_size=5): | |
self.board_size = board_size | |
# initialize board object | |
self._generate_board() | |
board = Board(board_size=6) | |
board.render_board() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment