Add files via upload

Noticed small typos.  Typos corrected.
Updated dimension input to alert user that dimensions above 5 may take time to produce.  Seems like the 8th dimension takes forever - I expect in either the 8th or 9th to run out of memory.
This commit is contained in:
neogeek23 2017-05-13 10:37:40 -05:00 committed by GitHub
parent 332a21eeca
commit 8812a19dfd

View File

@ -82,7 +82,7 @@ class Board:
if d < 3: if d < 3:
header = "\n " header = "\n "
for i in range(self.__dimensions + 1): for i in range(self.__dimensions + 1):
if i > 9: # lets be honest 100^99 will destroy memory; already dies a dim 8, 7 is struggle if i > 9: # lets be honest this will destroy memory; already dies at dim 8, 7 is struggle
header += "| " + str(i) header += "| " + str(i)
else: else:
header += "| " + str(i) + " " header += "| " + str(i) + " "
@ -281,6 +281,10 @@ dimension = int(difficulty)
if dimension < 2: if dimension < 2:
print("Tic Tac Toe requires at least 2 dimensions and you chose " + difficulty + ", so we will use 2 dimensions.") print("Tic Tac Toe requires at least 2 dimensions and you chose " + difficulty + ", so we will use 2 dimensions.")
dimension = 2 dimension = 2
else:
print("You have requested a board of " + str(math.pow(dimension + 1, dimension)) + " spaces.")
if dimension > 5:
print("This is a very large board. It may take some time to create.")
board = Board(dimension) board = Board(dimension)
if dimension > 2 and dimension % 2 == 0: if dimension > 2 and dimension % 2 == 0:
@ -334,7 +338,7 @@ while not board.is_full() and not board.has_winner():
# Reporting on End of Game # Reporting on End of Game
board.display() board.display()
if board.is_full(): if board.is_full():
print("Board has filled a no victor has been found. Game Over. Thanks for playing, try again.") print("Board has filled and no victor has been found. Game Over. Thanks for playing, try again.")
if board.has_winner(): if board.has_winner():
print("\nVictory to Player " + str(board.players[board.get_winner()].get_id() + 1) + " - respect. The " print("\nVictory to Player " + str(board.players[board.get_winner()].get_id() + 1) + " - respect. The "