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


Python Program.getDenyReason方法代码示例

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


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

示例1: DfpnSolver

# 需要导入模块: from program import Program [as 别名]
# 或者: from program.Program import getDenyReason [as 别名]
class DfpnSolver(Thread):
    class Error:
        pass

    def __init__(self, name, command, positions, verbose):
        Thread.__init__(self)
        self._name = name
        self._positions = positions
        self._verbose = verbose
        command = command + " --logfile-name=" + name + ".log"
        self._program = Program(command, verbose)

    def sendCommand(self, command):
        try:
            return self._program.sendCommand(command);
        except Program.CommandDenied:
            reason = self._program.getDenyReason()
            self._errorMessage = _name + ": "  + reason
            raise DfpnSolver.Error
        except Program.Died:
            self._errorMessage = _name + ": program died"
            raise DfpnSolver.Error

    def playVariation(self, variation):
        self.sendCommand("clear_board");
        moves = variation.split(' ');
        color = "B";
        for move in moves:
            cmd = "play " + color + " " + move.strip();
            self.sendCommand(cmd);
            if color == "B":
                color = "W";
            else:
                color = "B";
            
    def solvePosition(self, variation):
        if (self._verbose):
            print "#####################################"
            print self._name + ": " + variation
            print "#####################################"
        else:
            print self._name + ": " + variation
        self.playVariation(variation);
        return self.sendCommand("dfpn-solve-state");

    def addResult(self, variation, winner):
        if (winner == "empty"):
            f = open(self._name + ".unsolved", "a");
            print >> f, variation;
            f.close();
        else:
            f = open(self._name + ".solved", "a");
            print >> f, variation + " " + winner
            f.close();

    def run(self):
        while True:
            variation = self._positions.getPosition();
            if variation == "":
                return;
            else:
                winner = self.solvePosition(variation).strip();
                self.addResult(variation, winner);
                print self._name + ": " + winner
开发者ID:PawelTroka,项目名称:LogicalGamesEnginesGenerator,代码行数:66,代码来源:book-solve.py


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