def main(): g = TwoThousandFortyEight( board=[[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 1024, 1024]]) while not g.has_lost(): try: g.print_board() print('Waiting for input') g.parse_input() g.add_value_to_random_zeroed_cell() if g.has_won(): print('Congratulations! You won the game :)') except ValueError as e: print(str(e)) print('You lost')
def test_add_value_to_random_zeroed_cell_doesnt_overwrtie_non_zero(self): g = TwoThousandFortyEight( board=[[8, 8, 8, 8], [8, 8, 8, 8], [8, 8, 8, 8], [8, 8, 8, 0]]) g.add_value_to_random_zeroed_cell() self.assertTrue(g.board[3][3] in [2, 4])