コード例 #1
0
    def SetUp(self, options):
        #gameSetupParams: Player 1 and 2 Name, Color, Human/AI level
        if self.debugMode:
            player1Name = 'Steve'
            player1Type = 'human'
            player1Color = 'white'
            player2Name = 'Bob'
            player2Type = 'AI'
            player2Color = 'black'
        else:
            GameParams = TkinterGameSetupParams()
            (player1Name, player1Color, player1Type, player2Name, player2Color,
             player2Type) = GameParams.GetGameSetupParams()

        self.player = [0, 0]
        if player1Type == 'human':
            self.player[0] = ChessPlayer(player1Name, player1Color)
        else:
            self.player[0] = ChessAI(player1Name, player1Color)

        if player2Type == 'human':
            self.player[1] = ChessPlayer(player2Name, player2Color)
        else:
            self.player[1] = ChessAI(player2Name, player2Color)

        #create the gui object - didn't do earlier because pygame conflicts with any gui manager (Tkinter, WxPython...)
        if 't' in options:
            self.guitype = 'text'
            self.Gui = ChessGUI_text()
        else:
            self.guitype = 'pygame'
            if 'o' in options:
                self.Gui = ChessGUI_pygame(0)
            else:
                self.Gui = ChessGUI_pygame(1)
コード例 #2
0
    def SetUp(self, options):
        #gameSetupParams: Player 1 and 2 Name, Color, Human/AI level
        if self.debugMode:
            player1Name = 'Kasparov'
            player1Type = 'human'
            player1Color = 'white'
            player2Name = 'Light Blue'
            player2Type = 'randomAI'
            player2Color = 'black'
        else:
            GameParams = TkinterGameSetupParams()
            (player1Name, player1Color, player1Type, player2Name, player2Color,
             player2Type) = GameParams.GetGameSetupParams()

        self.player = [0, 0]
        if player1Type == 'human':
            self.player[0] = ChessPlayer(player1Name, player1Color)
        elif player1Type == 'randomAI':
            self.player[0] = ChessAI_random(player1Name, player1Color)
        elif player1Type == 'HeuristicOffense':
            self.player[0] = Off_Heuristic(player1Name, player1Color,
                                           self.Board)
        elif player1Type == 'EnemyOffense':
            self.player[0] = Off_Enemy(player1Name, player1Color, self.Board)

        if player2Type == 'human':
            self.player[1] = ChessPlayer(player2Name, player2Color)
        elif player2Type == 'randomAI':
            self.player[1] = ChessAI_random(player2Name, player2Color)
        elif player2Type == 'HeuristicDefense':
            self.player[1] = Def_Heuristic(player2Name, player2Color,
                                           self.Board)
        elif player2Type == 'EnemyDefense':
            self.player[1] = Def_Enemy(player2Name, player2Color, self.Board)

        if 'AI' in self.player[0].GetType() and 'AI' in self.player[1].GetType(
        ):
            self.AIvsAI = True
        else:
            self.AIvsAI = False

        if options.pauseSeconds > 0:
            self.AIpause = True
            self.AIpauseSeconds = int(options.pauseSeconds)
        else:
            self.AIpause = False

        #create the gui object - didn't do earlier because pygame conflicts with any gui manager (Tkinter, WxPython...)
        if options.text:
            self.guitype = 'text'
            self.Gui = ChessGUI_text()
        else:
            self.guitype = 'pygame'
            if options.old:
                self.Gui = ChessGUI_pygame(0)
            else:
                self.Gui = ChessGUI_pygame(1)
コード例 #3
0
    def SetUp(self, options):
        #gameSetupParams: Player 1 and 2 Name, Color, Human/AI level
        if self.debugMode:
            player1Name = 'Atahualpa'
            player1Type = 'humano'
            player1Color = 'blanco'
            player2Name = 'Huascar'
            player2Type = 'randomAI'
            player2Color = 'negro'
        else:
            GameParams = TkinterGameSetupParams()
            (player1Name, player1Color, player1Type, player2Name, player2Color,
             player2Type) = GameParams.GetGameSetupParams()

        self.player = [0, 0]
        self.redis = player1Type
        if player1Type == 'humano':
            self.player[0] = ChessPlayer(player1Name, player1Color)
        elif player1Type == 'server':
            self.player[0] = ChessPlayer(player1Name, player1Color)
        elif player1Type == 'client':
            self.player[0] = ChessPlayer(player2Name, player2Color)
        elif player1Type == 'offenseAI':
            self.player[0] = ChessAI_offense(player1Name, player1Color)

        if player2Type == 'humano':
            self.player[1] = ChessPlayer(player2Name, player2Color)
        elif player2Type == 'server':
            self.player[1] = ChessPlayer(player1Name, player1Color)
        elif player2Type == 'client':
            self.player[1] = ChessPlayer(player2Name, player2Color)
        elif player2Type == 'offenseAI':
            self.player[1] = ChessAI_offense(player2Name, player2Color)

        if options.pauseSeconds > 0:
            self.AIpause = True
            self.AIpauseSeconds = int(options.pauseSeconds)
        else:
            self.AIpause = False

        #create the gui object - didn't do earlier because pygame conflicts with any gui manager (Tkinter, WxPython...)
        if options.text:
            self.guitype = 'text'
            self.Gui = ChessGUI_text()
        else:
            self.guitype = 'pygame'
            if options.old:
                self.Gui = ChessGUI_pygame(0)
            else:
                self.Gui = ChessGUI_pygame(1)
コード例 #4
0
ファイル: PythonChessMain.py プロジェクト: kokoff/chess
    def SetUp(self):
        game_params = TkinterGameSetupParams()
        (player1Type, player1Depth, player2Type, player2Depth) = game_params.GetGameSetupParams()

        if player1Type == 'AI':
            if player1Depth > 0:
                self.ai_players[chess.WHITE] = AI(self.board, chess.WHITE, player1Depth)
            else:
                self.ai_players[chess.WHITE] = RandomAI()

        if player2Type == 'AI':
            if player2Depth > 0:
                self.ai_players[chess.BLACK] = AI(self.board, chess.BLACK, player2Depth)
            else:
                self.ai_players[chess.BLACK] = RandomAI(self.board)
コード例 #5
0
    def SetUp(self, options):
        #gameSetupParams: Player 1 and 2 Name, Color, Human/AI level
        if self.debugMode:
            player1Name = 'Kasparov'
            player1Type = 'human'
            player1Color = 'white'
            player2Name = 'Light Blue'
            player2Type = 'randomAI'
            player2Color = 'black'
        else:
            GameParams = TkinterGameSetupParams()
            (player1Name, player1Color, player1Type, player2Name, player2Color,
             player2Type) = GameParams.GetGameSetupParams()

        self.player = [0, 0]
        if player1Type == 'human':
            self.player[0] = ChessPlayer(player1Name, player1Color)
        elif player1Type == 'randomAI':
            self.player[0] = ChessAI_random(player1Name, player1Color)
        elif player1Type == 'defenseAI':
            self.player[0] = ChessAI_defense(player1Name, player1Color)
        elif player1Type == 'offenseAI':
            self.player[0] = ChessAI_offense(player1Name, player1Color)

        if player2Type == 'human':
            self.player[1] = ChessPlayer(player2Name, player2Color)
        elif player2Type == 'randomAI':
            self.player[1] = ChessAI_random(player2Name, player2Color)
        elif player2Type == 'defenseAI':
            self.player[1] = ChessAI_defense(player2Name, player2Color)
        elif player2Type == 'offenseAI':
            self.player[1] = ChessAI_offense(player2Name, player2Color)

        if 'AI' in self.player[0].GetType() and 'AI' in self.player[1].GetType(
        ):
            self.AIvsAI = True
        else:
            self.AIvsAI = False

        if options.pauseSeconds > 0:
            self.AIpause = True
            self.AIpauseSeconds = int(options.pauseSeconds)
        else:
            self.AIpause = False