当前位置: 首页>>代码示例>>Python>>正文


Python Problem.goalTest方法代码示例

本文整理汇总了Python中problem.Problem.goalTest方法的典型用法代码示例。如果您正苦于以下问题:Python Problem.goalTest方法的具体用法?Python Problem.goalTest怎么用?Python Problem.goalTest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在problem.Problem的用法示例。


在下文中一共展示了Problem.goalTest方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: initBattleSimulation

# 需要导入模块: from problem import Problem [as 别名]
# 或者: from problem.Problem import goalTest [as 别名]
    def initBattleSimulation(self, player1Algo, player2Algo, opponent, player2CuttingDepth):
        nextState = self.initialState
        player = self.player
        INFINITY = float('inf')
        outFile = open("trace_state.txt", "w")
        while not Problem.goalTest(nextState):
            if player == self.player: #first player
                if int(player1Algo) == 1:
                    nextState = self.greedyBFSBattle(nextState, player)
                elif int(player1Algo) == 2:
                    problemObj = Problem(nextState, self.boardValue,player)
                    node =  Node(nextState, None, self.cuttingDepth, -INFINITY, "root", problemObj, player)         
                    bestValue = self.minimaxBattle(node, self.cuttingDepth, True,problemObj)
                    nextState = self.getNextState(node, bestValue)
                elif int(player1Algo) == 3:
                    problemObj = Problem(nextState, self.boardValue,player)
                    node =  Node(nextState, None, self.cuttingDepth, -INFINITY, "root", problemObj, player)
                    bestValue = self.alphabetaBattle(node, self.cuttingDepth, -INFINITY, INFINITY, True, problemObj)
                    nextState = self.getNextState(node, bestValue)
            else: #opponent player
                if int(player2Algo) == 1:
                    nextState = self.greedyBFSBattle(nextState, opponent)
                elif int(player2Algo) == 2:
                    problemObj = Problem(nextState, self.boardValue, opponent)
                    node = Node(nextState, None, player2CuttingDepth, -INFINITY, "root", problemObj, opponent)
                    bestValue = self.minimaxBattle(node, player2CuttingDepth, True, problemObj)
                    nextState = self.getNextState(node, bestValue)
                elif int(player2Algo) == 3:
                    problemObj = Problem(nextState, self.boardValue, opponent)
                    node =  Node(nextState, None, player2CuttingDepth, -INFINITY, "root", problemObj, opponent)
                    bestValue = self.alphabetaBattle(node, player2CuttingDepth, -INFINITY, INFINITY, True, problemObj)
                    nextState = self.getNextState(node, bestValue)

            # self.printState(nextState)
            for x in nextState:
                outFile.write(''.join(x))
                outFile.write("\n")
            player = self.player if player == opponent else opponent

        outFile.close()
开发者ID:pnisarg,项目名称:ninjaSquirrels-,代码行数:42,代码来源:problemSolver.py


注:本文中的problem.Problem.goalTest方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。