當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。