def test_loop(self): solitaire_tantrix.MINIMAL_GRID_SIZE = 2 game_tantrix = Tantrix(2) game_tantrix.place_tile((0, 0, 6), 'RRYYBB') game_tantrix.place_tile((0, 1, 5), 'YRBBRY') game_tantrix.place_tile((1, 0, 5), 'YRRYBB') positions_to_remove = [] for pos in game_tantrix._tile_value: if pos not in ((0, 0, 6), (0, 1, 5), (1, 0, 5)): positions_to_remove.append(pos) for pos in positions_to_remove: game_tantrix.remove_tile(pos) self.assertEqual(game_tantrix.has_loop('B'), True) # test get all neighbors expected = [(0, 1, 5), (1, 0, 5)] self.assertEqual(game_tantrix.get_all_neighbors((0, 0, 6)), expected)
def test_legal_configurations(self): solitaire_tantrix.MINIMAL_GRID_SIZE = 1 game_tantrix = Tantrix(1) self.assertEqual(game_tantrix.is_legal(), True) # test get all neighbors self.assertEqual(game_tantrix.get_all_neighbors((0, 0, 6)), []) solitaire_tantrix.MINIMAL_GRID_SIZE = 2 game_tantrix = Tantrix(2) game_tantrix.place_tile((0, 0, 6), 'YYBBRR') game_tantrix.place_tile((0, 1, 5), 'RYYRBB') game_tantrix.place_tile((1, 0, 5), 'BBYRRY') positions_to_remove = [] for pos in game_tantrix._tile_value: if pos not in ((0, 0, 6), (0, 1, 5), (1, 0, 5)): positions_to_remove.append(pos) for pos in positions_to_remove: game_tantrix.remove_tile(pos) self.assertEqual(game_tantrix.is_legal(), True) game_tantrix.rotate_tile((0, 0, 6)) self.assertEqual(game_tantrix.is_legal(), False)