示例#1
0
        numGames= 5
        for i in range (0, numGames):
            winner= gl.gamePlay(playerMode1, playerMode2, trainPlies, 0)
            wins[winner]+=1
        final[playerMode1]+=  wins[1]
        final[playerMode2]+= wins[2]    
        fileText+= "With " + playerMode1 + "=1 and " + playerMode2 + "=2, wins: " + str(wins) + "\n"
        #time.sleep(3)
    fileText+= "Final Results:\n"
    fileText+= str(final) +"\n"
    fileText+= "--------------------------------------------------------------\n"
    
def autotest():
    global fileText, fileName, startIndexI, startIndexJ
    players= ["Random","RandomPlus","RandomPlus2","RandomPlusPlus",\
              "BestLocalPlus","lookAheadOne","lookAheadTwice",\
              "lookAheadThrice","lookAheadOnePlus","lookAheadTwicePlus","lookAheadThricePlus",\
              "randomOffense","randomOffenseWithTwicePlus","randomOffenseOneWithTwicePlus",\
              "knnPlayer","minimaxKnn", "minimaxSeqCellsPlus"]
    for i in range(startIndexI, len(players)):
        for j in range(startIndexJ, len(players)):
            battle( players[i], players[j] )
            with open(fileName, 'a') as f:
                f.write( fileText )
            fileText= ""
        startIndexJ= i + 1        
    
trainPlies= dict()
trainPlies[1]= glf.getData()
trainPlies[2]= glf.adjustData(trainPlies[1], 2)
autotest()
示例#2
0
def startGame(player1,player2):
    trainPlies= dict()
    trainPlies[1]= glf.getData()
    trainPlies[2]= glf.adjustData(trainPlies[1], 2)
    gl.gamePlay(player1, player2,trainPlies)