本文整理汇总了Python中board.Board.add_solution方法的典型用法代码示例。如果您正苦于以下问题:Python Board.add_solution方法的具体用法?Python Board.add_solution怎么用?Python Board.add_solution使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类board.Board
的用法示例。
在下文中一共展示了Board.add_solution方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_pluralizing
# 需要导入模块: from board import Board [as 别名]
# 或者: from board.Board import add_solution [as 别名]
def test_pluralizing(self):
# Pluralizing.
board = Board()
solution = Solution(Board.MID_ROW, Board.MID_COL - 1, HORIZONTAL, "DOG")
solution.determine_score(board, self.dic)
self.assertEqual(solution.score, 10)
board.add_solution(solution)
solution = Solution(Board.MID_ROW, Board.MID_COL - 1, HORIZONTAL, "DOGS")
solution.determine_score(board, self.dic)
self.assertEqual(solution.score, 6)
示例2: test2
# 需要导入模块: from board import Board [as 别名]
# 或者: from board.Board import add_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
示例3: test_two_blanks
# 需要导入模块: from board import Board [as 别名]
# 或者: from board.Board import add_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)
示例4: test_one_blank_generating_solution
# 需要导入模块: from board import Board [as 别名]
# 或者: from board.Board import add_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)
示例5: test_cross_with_blank
# 需要导入模块: from board import Board [as 别名]
# 或者: from board.Board import add_solution [as 别名]
def test_cross_with_blank(self):
dic = Dictionary()
dic.set_words(["SA","JETS"])
board = Board()
board.add_word('JET', 5, 4, VERTICAL)
sol= Solution(8, 4, HORIZONTAL, 'SA', [])
sol.determine_score(board, dic)
self.assertEqual(sol.score, 13)
sol= Solution(8, 4, HORIZONTAL, 'SA', [0])
sol.determine_score(board, dic)
self.assertEqual(sol.score, 11)
board.add_solution(sol)
示例6: test1
# 需要导入模块: from board import Board [as 别名]
# 或者: from board.Board import add_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
示例7: __init__
# 需要导入模块: from board import Board [as 别名]
# 或者: from board.Board import add_solution [as 别名]
#.........这里部分代码省略.........
#speech.speak(solution)
else:
pass
# Should put letters back in bag.
print board
print 'old board at the beginningof 2 - 1'
print self.old_board
# Wait for "Enter", signifying the player has completed his/her turn.
#self.wait = raw_input("Press enter when finished with move")
# Get word that was just played on the board by fetching the new board state.
self.update_board = Board()
print 'old board at the beginningof 2 - 2'
print self.old_board
board1 = board_vision.get_board(self.classify,self.cam1)
board2 = board_vision.get_board(self.classify,self.cam1)
board3 = board_vision.get_board(self.classify,self.cam1)
print 'old board at the beginningof 2 - 3'
print self.old_board
correctboard = [None] *15*15
for i in range(len(board1)):
if board1[i]==board2[i] or board1[i]==board3[i]:
correctboard[i] = board1[i]
elif board2[i]==board3[i]:
correctboard[i] = board2[i]
self.update_board.set_cells(correctboard)
print 'old board at the beginningof 2 - 4'
print self.old_board
self.gui.full_board_update(copy.deepcopy(self.update_board.cells))
print 'old board at the end gof 2'
print self.old_board
def main3(self):
print self.update_board
print self.old_board
self.move,self.letter_placed_on_board = self.board.get_played_word(self.update_board,self.old_board,self.dictionary)
print ("The word:"+ self.move.word +"was just played.")
for char in self.letter_placed_on_board:
self.rack = self.rack.replace(char,"")
#rack_list = self.letter_placed_on_board.split()
self.move.rack_indices = self.letter_placed_on_board
self.board.add_solution(self.move)
if (self.move.word == self.solution.word):
print("Player listened to Baxter")
else:
print("defied Baxter")
if (self.move.score != None):
self.my_score+=self.move.score
if len(self.move.rack_indices) == 7:
self.my_score+=50
print "Baxter's Score: %d" % self.my_score
festival.setStretchFactor(1)
festival.sayText("Good Move")
self.gui.log.write('Good job, your score is now: ' + str(self.my_score))
#generate_rack(self.rack,self.old_rack,self.bag)
for char in self.letter_placed_on_board:
self.rack = self.rack.replace(char,"")
self.old_board = Board()
self.old_board.set_cells(self.update_board.cells)
print 'oldboard set to'
print self.old_board
print ("count:"+str(self.count))
def main4(self):
print "Baxter's Score: %d" % self.my_score
print "Baxter's Words:"
for self.rack,self.winner in self.winners:
print " %s: %s" % (self.rack, self.winner)
def fixboard(self,boardcells):
print self.old_board
self.update_board = Board()
self.update_board.set_cells(copy.deepcopy(boardcells))
print self.old_board
# if __name__ == "__main__":
# try:
# main2()
# except rospy.ROSInterruptException:
# pass