本文整理汇总了Python中Dictionary.Dictionary.get_first_word方法的典型用法代码示例。如果您正苦于以下问题:Python Dictionary.get_first_word方法的具体用法?Python Dictionary.get_first_word怎么用?Python Dictionary.get_first_word使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Dictionary.Dictionary
的用法示例。
在下文中一共展示了Dictionary.get_first_word方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: GameManager
# 需要导入模块: from Dictionary import Dictionary [as 别名]
# 或者: from Dictionary.Dictionary import get_first_word [as 别名]
class GameManager(QtCore.QObject):
start_move_first = QtCore.Signal()
start_move_second = QtCore.Signal()
ask_for_cells = QtCore.Signal()
game_ended = QtCore.Signal(str)
show_board = QtCore.Signal()
@QtCore.Slot()
def step_ended(self):
if self.__current_id__ == FIRST_PLAYER:
self.__current_id__ = SECOND_PLAYER
else:
self.__current_id__ = FIRST_PLAYER
self.__number_of_spare_cells__ -= 1
@QtCore.Slot(int)
def get_number_of_cells(self, value):
self.__number_of_spare_cells__ = value
@QtCore.Slot()
def game_ending(self):
message = None
if self.__players_number__ == 2:
score1 = self.__player1__.get_score()
score2 = self.__player2__.get_score()
if score1 > score2:
message = 'First player win'
elif score1 == score2:
message = 'Draw'
else:
message = 'Second player win'
else:
score1 = self.__player1__.get_score()
score2 = self.__player2__.get_score()
if score1 > score2:
message = 'You win'
elif score1 == score2:
message = 'Draw'
else:
message = 'Computer win'
self.game_ended.emit(message)
def __init__(self, language: Language, width, height, players_number, level=''):
super(GameManager, self).__init__()
self.__bot__ = Bot(language, width, height)
self.__width__ = width
self.__height__ = height
self.__players_number__ = players_number
self.__board__= Board()
self.__board__.init_board(width, height)
self.__dictionary__ = Dictionary()
self.__dictionary__.load_dictionary()
self.__wc__ = WordCollector()
self.__wc__.connect_to_dictionary(self.__dictionary__)
self.__wc__.connect_to_board(self.__board__)
self.__dictionary__.setup_connection(self.__wc__)
self.__board__.setup_connection(self.__wc__)
self.__first_word__ = self.__dictionary__.get_first_word(width)
self.__player1__ = Player()
self.__player2__ = Player()
if players_number == 2:
self.__player1__.connect_to_board(self.__board__)
self.__player1__.connect_to_manager(self)
self.__player2__.connect_to_board(self.__board__)
self.__player2__.connect_to_manager(self)
else:
self.__player1__.connect_to_board(self.__board__)
self.__player1__.connect_to_manager(self)
self.__dictionary__.connect_to_bot(self.__bot__)
self.__dictionary__.used_words_to_bot(self.__bot__)
if level == 'EASY':
self.__bot__.set_level(EASY)
elif level == 'MEDIUM':
self.__bot__.set_level(MEDIUM)
elif level == 'HARD':
self.__bot__.set_level(HARD)
elif level == 'HARDEST':
self.__bot__.set_level(HARDEST)
self.__bot__.connect_to_board(self.__board__)
self.__bot__.connect_to_manager(self)
self.__bot__.connect_to_dictionary(self.__dictionary__)
self.__bot__.get_dictionary()
self.__bot__.connect_to_used_dictionary(self.__dictionary__)
self.__current_player__ = self.__player1__
self.__current_id__ = FIRST_PLAYER
self.__number_of_spare_cells__ = width*(height - 1)
#.........这里部分代码省略.........