コード例 #1
0
    def test_get_best_move_one_moves(self):
        # Vertical word bottom left
        # given
        wor = [('cider', 2)]
        wob = [{'word': 'car', 'x': 12, 'y': 11, 'isHorizontal': False}]
        dictionary = {'acir': ['icar', 'cari']}

        # when
        result = sb.get_best_move(wor, wob, dictionary)

        # then
        self.assertEqual(len(result), 1)
        self.assertEqual(result[0]['x'], 11)
        self.assertEqual(result[0]['y'], 10)
コード例 #2
0
    def test_get_best_move_no_move(self):

        # Horizontal word top left
        # given
        wor = [('cider', 2)]
        wob = [{'word': 'car', 'x': 1, 'y': 0, 'is_horizontal': True}]
        dictionary = {'acir': ['icar', 'cari']}
        board = [['-', '-', '-', '-'], ['c', 'a', 'r', '-'],
                 ['-', '-', '-', '-'], ['-', '-', '-', '-']]

        # when
        result = sb.get_best_move(board, wor, wob, dictionary)

        # then
        self.assertEqual(len(result), 0)
コード例 #3
0
    def test_get_best_move_two_moves(self):

        # Horizontal word top left
        # given
        wor = [('cider', 2)]
        wob = [{'word': 'car', 'x': 1, 'y': 1, 'isHorizontal': True}]
        dictionary = {'acir': ['icar', 'cari']}

        # when
        result = sb.get_best_move(wor, wob, dictionary)

        # then
        self.assertEqual(len(result), 2)
        self.assertEqual(result[0]['x'], 0)
        self.assertEqual(result[0]['y'], 0)
        self.assertEqual(result[1]['x'], 0)
        self.assertEqual(result[1]['y'], 4)
コード例 #4
0
    def test_get_best_move_one_move_horizontal(self):
        # Vertical word bottom left
        # given
        wor = [('cider', 2)]
        wob = [{'word': 'car', 'x': 3, 'y': 2, 'is_horizontal': False}]
        dictionary = {'acir': ['icar', 'cari']}
        board = [['-', '-', '-', '-', '-',
                  '-'], ['-', '-', '-', '-', '-', '-'],
                 ['-', '-', '-', '-', '-',
                  '-'], ['-', '-', 'c', '-', '-', '-'],
                 ['-', '-', 'a', '-', '-', '-'],
                 ['-', '-', 'r', '-', '-', '-']]

        # when
        result = sb.get_best_move(board, wor, wob, dictionary)

        # then
        self.assertEqual(len(result), 1)
        self.assertEqual(result[0]['x'], 2)
        self.assertEqual(result[0]['y'], 1)