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


Python Program.getResult方法代码示例

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


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

示例1: playGame

# 需要导入模块: from program import Program [as 别名]
# 或者: from program.Program import getResult [as 别名]
    def playGame(self, gameIndex, currentRound, 
                 blackName, blackCmd, whiteName, whiteCmd,
                 opening, verbose):
        if verbose:
            print
            print "==========================================================="
            print "Game ", gameIndex
            print "==========================================================="
            
        bcmd = "nice " + blackCmd + " --seed %SRAND" \
               + " --logfile-name " + self._outdir + "/"  \
               + blackName + "-" + str(gameIndex) + ".log"
        wcmd = "nice " + whiteCmd + " --seed %SRAND" \
               + " --logfile-name " + self._outdir + "/"  \
               + whiteName + "-" + str(gameIndex) + ".log"
        bLogName = self._outdir + "/" + blackName + "-" + str(gameIndex) \
                          + "-stderr.log"
        wLogName = self._outdir + "/" + whiteName + "-" + str(gameIndex) \
                          + "-stderr.log"
        black = Program("B", bcmd, bLogName, verbose)
        white = Program("W", wcmd, wLogName, verbose)
        
        resultBlack = "?"
        resultWhite = "?"
        error = 0
        errorMessage = ""
        game = Game()  # just a temporary
        gamePlayer = GamePlayer(black, white, self._size)
        try:
            game = gamePlayer.play(opening, verbose)
            swapped = game.playedSwap()
            resultBlack = self.handleResult(swapped, black.getResult())
            resultWhite = self.handleResult(swapped, white.getResult())
        except GamePlayer.Error:
            error = 1
            errorMessage = gamePlayer.getErrorMessage()
        except Program.Died:
            error = 1
            errorMessage = "program died"

        name = "%s/%04i" % (self._outdir, gameIndex)

        # save the result
        # recall it has been flipped if a swap move was played
        result = "?"
        if resultBlack == resultWhite:
            result = resultBlack
        game.setResult(result)

        # save it to the results file
        self._resultsFile.addResult(currentRound, opening,
                                    blackName, whiteName,
                                    resultBlack, resultWhite,
                                    # -1 so we don't count "resign" as a move
                                    game.getLength()-1,
                                    game.getElapsed("black"),
                                    game.getElapsed("white"),
                                    error, errorMessage)

        # save game
        gamePlayer.save(name + ".sgf", name, resultBlack, resultWhite)
        if error:
            print "Error: Game", gameIndex
        for program in [black, white]:
            try:
                program.sendCommand("quit");
            except Program.Died:
                pass
            
        return game
开发者ID:PawelTroka,项目名称:LogicalGamesEnginesGenerator,代码行数:72,代码来源:tournament.py

示例2: randomOpening

# 需要导入模块: from program import Program [as 别名]
# 或者: from program.Program import getResult [as 别名]
    print "Error during initialization!"
    print gamePlayer.getErrorMessage()
except Program.Died:
    print "Error during initialization!"
    print "program died"
   
opening = randomOpening(size, seed / 2)
resultBlack = "?"
resultWhite = "?"
error = 0
errorMessage = ""
game = Game()  # just a temporary
gamePlayer = GamePlayer(black, white, size)
try:
    game = gamePlayer.play(opening, verbose)
    resultBlack = black.getResult()
    resultWhite = white.getResult()
    filename = path + ("/%07d.sgf" % seed)
    gamePlayer.save(filename, seed, resultBlack, resultWhite)

    result = "?"
    if resultBlack == resultWhite:
        result = resultBlack

    if result == '?':
        print "Error: could not determine game result"
    elif 'B+' in result:
        if (seed % 2 == 0):  # seed even ==> black == opt
            print "W"
        else:
            print "L"
开发者ID:kenjyoung,项目名称:benzene-vanilla,代码行数:33,代码来源:MoHexScript.py


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