def test(self): twenty_forty_eight = TwentyFortyEight() self.assertEqual(twenty_forty_eight._grid_height, 4) self.assertEqual(twenty_forty_eight._grid_width, 4) twenty_forty_eight = TwentyFortyEight(4, 5) self.assertEqual(twenty_forty_eight._grid_height, 4) self.assertEqual(twenty_forty_eight._grid_width, 5)
def test(self): twenty_forty_eight = TwentyFortyEight(6, 4) empty_grid = twenty_forty_eight.generate_empty_grid() twenty_forty_eight.grid = empty_grid self.assertEqual( twenty_forty_eight.__str__(), '[[0, 0, 0, 0],\n [0, 0, 0, 0],\n [0, 0, 0, 0],\n [0, 0, 0, 0],\n [0, 0, 0, 0],\n [0, 0, 0, 0]]' )
def test(self): twenty_forty_eight = TwentyFortyEight() empty_grid = twenty_forty_eight.generate_empty_grid() twenty_forty_eight.grid = empty_grid twenty_forty_eight.set_tile(0, 2, 2) self.assertEqual(twenty_forty_eight.check_tile_is_empty(0, 2), False) self.assertEqual(twenty_forty_eight.check_tile_is_empty(0, 0), True)
def test(self): twenty_forty_eight = TwentyFortyEight(6, 4) twenty_forty_eight.reset() self.assertEquals(self.tiles_greater_zero(twenty_forty_eight._grid), 2) self.assertEquals( self.sum_of_tiles(twenty_forty_eight._grid) > 0, True) twenty_forty_eight = TwentyFortyEight(7, 18) twenty_forty_eight.reset() self.assertEquals(self.tiles_greater_zero(twenty_forty_eight._grid), 2) self.assertEquals( self.sum_of_tiles(twenty_forty_eight._grid) > 0, True)
def test(self): twenty_forty_eight = TwentyFortyEight() empty_grid = twenty_forty_eight.generate_empty_grid() twenty_forty_eight.grid = empty_grid twenty_forty_eight.set_tile(0, 2, 2) twenty_forty_eight.set_tile(0, 3, 4) twenty_forty_eight.set_tile(1, 2, 2) [ self.check_get_empty_tile(twenty_forty_eight) for dummy_num in range(5) ]
def test(self): twenty_forty_eight = TwentyFortyEight() move_grid_indices = twenty_forty_eight.move_grid_indices self.assertEqual(move_grid_indices[1], [(0, 0), (0, 1), (0, 2), (0, 3)]) self.assertEqual(move_grid_indices[2], [(3, 0), (3, 1), (3, 2), (3, 3)]) self.assertEqual(move_grid_indices[4], [(0, 3), (1, 3), (2, 3), (3, 3)]) self.assertEqual(move_grid_indices[3], [(0, 0), (1, 0), (2, 0), (3, 0)])
def test(self): twenty_forty_eight = TwentyFortyEight() empty_grid = twenty_forty_eight.generate_empty_grid() twenty_forty_eight.grid = empty_grid self.assertEqual( 0 <= twenty_forty_eight.get_random_row_index() < twenty_forty_eight.grid_height, True) self.assertEqual( 0 <= twenty_forty_eight.get_random_col_index() < twenty_forty_eight.grid_width, True)
def test(self): game = TwentyFortyEight(4, 3) self.set_up_game(game, 1) # UP self.assertEqual(game.grid, [[0, 2, 4], [0, 0, 2], [0, 0, 0], [0, 0, 0]]) self.set_up_game(game, 2) # DOWN self.assertEqual(game.grid, [[0, 0, 0], [0, 0, 0], [0, 0, 2], [0, 2, 4]]) self.set_up_game(game, 3) # LEFT self.assertEqual(game.grid, [[4, 0, 0], [0, 0, 0], [2, 0, 0], [2, 0, 0]]) self.set_up_game(game, 4) #RIGHT self.assertEqual(game.grid, [[0, 0, 4], [0, 0, 0], [0, 0, 2], [0, 0, 2]])
from game_template import TwentyFortyEight print "DOWN" game = TwentyFortyEight(4, 3) game.reset() game.new_tile() game.new_tile() print game.__str__() game.move(2) print game.__str__() print "UP" game = TwentyFortyEight(4, 3) game.reset() game.new_tile() game.new_tile() print game.__str__() print "\n" game.move(1) print game.__str__() print "RIGHT" game = TwentyFortyEight(4, 3) game.reset() game.new_tile() game.new_tile() print game.__str__() print "\n" game.move(4) print game.__str__()
def test(self): twenty_forty_eight = TwentyFortyEight(6, 4) self.assertEqual(twenty_forty_eight.generate_empty_grid(), [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]])
def test(self): twenty_forty_eight = TwentyFortyEight(6, 4) empty_grid = twenty_forty_eight.generate_empty_grid() twenty_forty_eight.grid = empty_grid twenty_forty_eight.new_tile() self.assertEquals(tiles_greater_zero(twenty_forty_eight._grid), 1) self.assertEquals(sum_of_tiles(twenty_forty_eight._grid) > 0, True) twenty_forty_eight = TwentyFortyEight() empty_grid = twenty_forty_eight.generate_empty_grid() twenty_forty_eight.grid = empty_grid twenty_forty_eight.new_tile() [twenty_forty_eight.new_tile() for dummy_num in range(9)] self.assertEquals(tiles_greater_zero(twenty_forty_eight._grid), 10) self.assertEquals(sum_of_tiles(twenty_forty_eight._grid) > 0, True)
[[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]) class StrTwentyFortyEightTest1(unittest.TestCase): def test(self): twenty_forty_eight = TwentyFortyEight(6, 4) empty_grid = twenty_forty_eight.generate_empty_grid() twenty_forty_eight.grid = empty_grid self.assertEqual( twenty_forty_eight.__str__(), '[[0, 0, 0, 0],\n [0, 0, 0, 0],\n [0, 0, 0, 0],\n [0, 0, 0, 0],\n [0, 0, 0, 0],\n [0, 0, 0, 0]]' ) twenty_forty_eight = TwentyFortyEight(6, 4) empty_grid = twenty_forty_eight.generate_empty_grid() twenty_forty_eight.grid = empty_grid class SelectTileIndexTwentyFortyEightTest1(unittest.TestCase): def test(self): self.assertIsInstance(twenty_forty_eight.select_tile(), tuple) row, col = twenty_forty_eight.select_tile() self.assertEquals(0 <= row < 6, True) self.assertEquals(0 <= col < 4, True) class SetTileTwentyFortyEightTest1(unittest.TestCase): def test(self): twenty_forty_eight.set_tile(0, 2, 2)