当前位置: 首页>>代码示例>>Python>>正文


Python Board.find_best_solution方法代码示例

本文整理汇总了Python中board.Board.find_best_solution方法的典型用法代码示例。如果您正苦于以下问题:Python Board.find_best_solution方法的具体用法?Python Board.find_best_solution怎么用?Python Board.find_best_solution使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在board.Board的用法示例。


在下文中一共展示了Board.find_best_solution方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_normal_find

# 需要导入模块: from board import Board [as 别名]
# 或者: from board.Board import find_best_solution [as 别名]
 def test_normal_find(self):
     # Normal find.
     board = Board()
     rack = "HELLOXX"
     solutions = board.generate_solutions(rack, self.dic)
     solution = board.find_best_solution(solutions, self.dic)
     self.assertIsNot(solution, None)
     self.assertEqual(solution.word, "HELLO")
开发者ID:flibustenet,项目名称:scrabble,代码行数:10,代码来源:test_blank.py

示例2: test_one_blank_forcing_solution

# 需要导入模块: from board import Board [as 别名]
# 或者: from board.Board import find_best_solution [as 别名]
 def test_one_blank_forcing_solution(self):
     # One blank, forcing solution.
     board = Board()
     rack = "HELL?XX"
     solutions = [Solution(7, 3, HORIZONTAL, "HELLO", [3])]
     solution = board.find_best_solution(solutions, self.dic)
     self.assertIsNot(solution, None)
     self.assertEqual(solution.word, "HELLO")
     self.assertEqual(solution.score, 22)
开发者ID:flibustenet,项目名称:scrabble,代码行数:11,代码来源:test_blank.py

示例3: test2

# 需要导入模块: from board import Board [as 别名]
# 或者: from board.Board import find_best_solution [as 别名]
def test2():
    dictionary = Dictionary()
    dictionary.set_words(["KISSED"])
    board = Board()
    rack = "KISSEDQ"
    solutions = board.generate_solutions(rack, dictionary)
    solution = board.find_best_solution(solutions, dictionary)
    if solution:
        print "Winner: %s" % solution
        board.add_solution(solution)
    print board
    assert solution and solution.score == 32
开发者ID:flibustenet,项目名称:scrabble,代码行数:14,代码来源:test2.py

示例4: test_two_blanks

# 需要导入模块: from board import Board [as 别名]
# 或者: from board.Board import find_best_solution [as 别名]
 def test_two_blanks(self):
     # Two blanks.
     board = Board()
     rack = "HEL??XX"
     solutions = board.generate_solutions(rack, self.dic)
     solution = board.find_best_solution(solutions, self.dic)
     print rack
     print solution
     board.add_solution(solution)
     print board
     self.assertIsNot(solution, None)
     self.assertEqual(solution.word, "HELLO")
     self.assertEqual(solution.score, 20)
开发者ID:flibustenet,项目名称:scrabble,代码行数:15,代码来源:test_blank.py

示例5: test_one_blank_generating_solution

# 需要导入模块: from board import Board [as 别名]
# 或者: from board.Board import find_best_solution [as 别名]
 def test_one_blank_generating_solution(self):
     # One blank, generating solution.
     board = Board()
     rack = "HELL?XX"
     solutions = board.generate_solutions(rack, self.dic)
     solution = board.find_best_solution(solutions, self.dic)
     print rack
     print solution
     board.add_solution(solution)
     print board
     self.assertIsNot(solution, None)
     self.assertEqual(solution.word, "HELLO")
     self.assertEqual(solution.score, 22)
开发者ID:flibustenet,项目名称:scrabble,代码行数:15,代码来源:test_blank.py

示例6: test_two_letter_one_blank

# 需要导入模块: from board import Board [as 别名]
# 或者: from board.Board import find_best_solution [as 别名]
    def test_two_letter_one_blank(self):
        dic = Dictionary()
        dic.set_words(["DUCE","EGRUGEAI"])

        board = Board()
        board.add_word('DUCE', 7, 4, HORIZONTAL)
        sol= Solution(7, 7, VERTICAL, 'EGRUGEAI', [1]) 
        sol.determine_score(board, dic)
        sol= Solution(7, 7, VERTICAL, 'EGRUGEAI', [4]) 
        sol.determine_score(board, dic)

        solutions = board.generate_solutions('RUIAG?E', dic)
        solution = board.find_best_solution(solutions, dic)
        self.assertEqual(solution.score, 80)
开发者ID:flibustenet,项目名称:scrabble,代码行数:16,代码来源:test_score.py

示例7: test1

# 需要导入模块: from board import Board [as 别名]
# 或者: from board.Board import find_best_solution [as 别名]
def test1():
    dictionary = Dictionary()
    dictionary.set_words(["OOZ", "OOZS", "PROSAIC", "PROC", "CC"])
    board = Board()

    # With this bug we'll get "PROC" but we want "PROSAIC" (where the S is the plural
    # of "OOS"), which is longer.
    board.add_word("OOZ", Board.SIZE/2, Board.SIZE/2 - 2, HORIZONTAL)
    board.add_word("CC", Board.SIZE/2 + 1, Board.SIZE/2 - 2, HORIZONTAL)

    rack = "PROSAIC"
    solutions = board.generate_solutions(rack, dictionary)
    solution = board.find_best_solution(solutions, dictionary)
    if solution:
        print "Winner: %s" % solution
        board.add_solution(solution)
    print board
开发者ID:flibustenet,项目名称:scrabble,代码行数:19,代码来源:test1.py


注:本文中的board.Board.find_best_solution方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。