Ejemplo n.º 1
0
 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)
Ejemplo n.º 2
0
    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[:]
Ejemplo n.º 3
0
    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
Ejemplo n.º 4
0
 def test_valid_input_number(self):
     self.assertFalse(game.valid('45'))
Ejemplo n.º 5
0
 def test_valid_input_multiple_char(self):
     self.assertFalse(game.valid('ggg'))