def test_game(self): """ This test run tests on the number of moves that are made by the breadth first algorithm by testing the valid function in game.py """ self.assertEqual(game.valid(game.maze,[10]),True)
def getMoves(self, maze): moves = [] if game.valid(self.cord[0] + 1, self.cord[1], maze) and self.__valid( self.cord[0] + 1, self.cord[1], maze): moves += [[self.cord[0] + 1, self.cord[1]]] if game.valid(self.cord[0] - 1, self.cord[1], maze) and self.__valid( self.cord[0] - 1, self.cord[1], maze): moves += [[self.cord[0] - 1, self.cord[1]]] if game.valid(self.cord[0], self.cord[1] + 1, maze) and self.__valid( self.cord[0], self.cord[1] + 1, maze): moves += [[self.cord[0], self.cord[1] + 1]] if game.valid(self.cord[0], self.cord[1] - 1, maze) and self.__valid( self.cord[0], self.cord[1] - 1, maze): moves += [[self.cord[0], self.cord[1] - 1]] return moves[:]
def place(self, val): row, col = self.selected if self.cubes[row][col].value == 0: self.cubes[row][col].set(val) self.update_model() if valid(self.model, val, (row, col)) and solve(self.model): return True else: self.cubes[row][col].set(0) self.cubes[row][col].set_temp(0) self.update_model() return False
def test_valid_input_number(self): self.assertFalse(game.valid('45'))
def test_valid_input_multiple_char(self): self.assertFalse(game.valid('ggg'))