當前位置: 首頁>>代碼示例>>Python>>正文


Python Dictionary.get_first_word方法代碼示例

本文整理匯總了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)
#.........這裏部分代碼省略.........
開發者ID:Medanya,項目名稱:Balda,代碼行數:103,代碼來源:GameManager.py


注:本文中的Dictionary.Dictionary.get_first_word方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。