Ejemplo n.º 1
0
 def test_find_words_vertical_parallel(self):
     game = Game()
     game.board[Board.MIDDLE[0]][Board.MIDDLE[1]] = self.B
     game.board[Board.MIDDLE[0] + 1][Board.MIDDLE[1]] = self.B
     game.board.is_empty = False
     words = game.find_words(
         Orientation.VERTICAL,
         [(Board.MIDDLE[0], Board.MIDDLE[1] + 1, self.A),
          (Board.MIDDLE[0] + 1, Board.MIDDLE[1] + 1, self.A)])
     self.assertListEqual(
         words, [[(Board.MIDDLE[0], Board.MIDDLE[1] + 1, self.A),
                  (Board.MIDDLE[0] + 1, Board.MIDDLE[1] + 1, self.A)],
                 [(Board.MIDDLE[0], Board.MIDDLE[1], self.B),
                  (Board.MIDDLE[0], Board.MIDDLE[1] + 1, self.A)],
                 [(Board.MIDDLE[0] + 1, Board.MIDDLE[1], self.B),
                  (Board.MIDDLE[0] + 1, Board.MIDDLE[1] + 1, self.A)]])
Ejemplo n.º 2
0
 def test_find_words_extend_below(self):
     game = Game()
     game.board[Board.MIDDLE[0] - 1][Board.MIDDLE[1]] = self.A
     game.board[Board.MIDDLE[0] - 2][Board.MIDDLE[1]] = self.A
     game.board[Board.MIDDLE[0] - 3][Board.MIDDLE[1]] = self.A
     game.board.is_empty = False
     words = game.find_words(
         Orientation.VERTICAL,
         [(Board.MIDDLE[0], Board.MIDDLE[1], self.A),
          (Board.MIDDLE[1] + 1, Board.MIDDLE[1], self.A)])
     self.assertListEqual(
         words, [[(Board.MIDDLE[0] - 3, Board.MIDDLE[1], self.A),
                  (Board.MIDDLE[0] - 2, Board.MIDDLE[1], self.A),
                  (Board.MIDDLE[0] - 1, Board.MIDDLE[1], self.A),
                  (Board.MIDDLE[0], Board.MIDDLE[1], self.A),
                  (Board.MIDDLE[0] + 1, Board.MIDDLE[1], self.A)]])
Ejemplo n.º 3
0
 def test_find_words_extend_right(self):
     game = Game()
     game.board[Board.MIDDLE[0]][Board.MIDDLE[1] - 1] = self.L
     game.board[Board.MIDDLE[0]][Board.MIDDLE[1] - 2] = self.L
     game.board[Board.MIDDLE[0]][Board.MIDDLE[1] - 3] = self.L
     game.board.is_empty = False
     words = game.find_words(
         Orientation.HORIZONTAL,
         [(Board.MIDDLE[0], Board.MIDDLE[0], self.A),
          (Board.MIDDLE[0], Board.MIDDLE[0] + 1, self.A)])
     self.assertListEqual(
         words, [[(Board.MIDDLE[0], Board.MIDDLE[1] - 3, self.L),
                  (Board.MIDDLE[0], Board.MIDDLE[1] - 2, self.L),
                  (Board.MIDDLE[0], Board.MIDDLE[1] - 1, self.L),
                  (Board.MIDDLE[0], Board.MIDDLE[1], self.A),
                  (Board.MIDDLE[0], Board.MIDDLE[1] + 1, self.A)]])
Ejemplo n.º 4
0
 def test_find_words_horizontal_parallel(self):
     game = Game()
     game.board[Board.MIDDLE[0]][Board.MIDDLE[1]] = self.R
     game.board[Board.MIDDLE[0]][Board.MIDDLE[1] + 1] = self.R
     game.board[Board.MIDDLE[0]][Board.MIDDLE[1] + 2] = self.R
     game.board.is_empty = False
     words = game.find_words(
         Orientation.HORIZONTAL,
         [(Board.MIDDLE[0] + 1, Board.MIDDLE[1], self.A),
          (Board.MIDDLE[0] + 1, Board.MIDDLE[1] + 1, self.A)])
     self.assertListEqual(
         words, [[(Board.MIDDLE[0] + 1, Board.MIDDLE[1], self.A),
                  (Board.MIDDLE[0] + 1, Board.MIDDLE[1] + 1, self.A)],
                 [(Board.MIDDLE[0], Board.MIDDLE[1], self.R),
                  (Board.MIDDLE[0] + 1, Board.MIDDLE[1], self.A)],
                 [(Board.MIDDLE[0], Board.MIDDLE[1] + 1, self.R),
                  (Board.MIDDLE[0] + 1, Board.MIDDLE[1] + 1, self.A)]])