Ejemplo n.º 1
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

        #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)
Ejemplo n.º 2
0
    def SetUp(self, whiteType, blackType):
        self.player = [0, 0]
        if whiteType == "defense":
            self.player[0] = ChessAI_defense("Defense AI - white", "white")
        elif whiteType == "offense":
            self.player[0] = ChessAI_offense("Offense AI - white", "white")
        else:
            self.player[0] = ChessAI_random("Random AI - white", "white")

        if blackType == "defense":
            self.player[1] = ChessAI_defense("Defense AI - black", "black")
        elif blackType == "offense":
            self.player[1] = ChessAI_offense("Offense AI - black", "black")
        else:
            self.player[1] = ChessAI_random("Random AI - black", "black")
Ejemplo n.º 3
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