def handlePerformedActionShow(words, writeFile):
    global opponentName
    global numBoardCards
    global preflopBets
    global postflopBets
    global turnBets
    global riverBets
    global boardCards
    global d

    if(words[5] == opponentName):
        opponentHand = []
        for card in words[1:5]:
            opponentHand.append(parseCard(card))
        preflopRating = Pokerini.pokeriniLookup(opponentHand, d)
        writeFile.write(str(preflopRating)+","+','.join(preflopBets))
        writeFile.write('\n')
        if(numBoardCards >= 3):
            postflopRanking = Simulation.simulateOld(opponentHand, boardCards[0:3], 3, 100)
            writeFile.write(str(postflopRanking)+","+','.join(postflopBets))
            writeFile.write('\n')
        if(numBoardCards >= 4):
            turnRanking = Simulation.simulateOld(opponentHand, boardCards[0:4], 4, 100)
            writeFile.write(str(turnRanking)+","+','.join(turnBets))
            writeFile.write('\n')
        if(numBoardCards == 5):
            riverRanking = Simulation.simulateOld(opponentHand, boardCards[0:5], 5, 100)
            writeFile.write(str(riverRanking)+","+','.join(riverBets))
            writeFile.write('\n')
Exemple #2
0
def handlePerformedActionShow(words, writeFile):
    global myName
    global numBoardCards
    global preflopBets
    global postflopBets
    global turnBets
    global riverBets
    global boardCards
    global d

    if (words[5] == myName):
        myHand = []
        for card in words[1:5]:
            myHand.append(parseCard(card))
        preflopRating = Pokerini.pokeriniLookup(myHand, d)
        writeFile.write(str(preflopRating) + "," + ','.join(preflopBets))
        writeFile.write('\n')
        if (numBoardCards >= 3):
            postflopRanking = Simulation.simulateOld(myHand, boardCards[0:3],
                                                     3, 100)
            writeFile.write(
                str(postflopRanking) + "," + ','.join(postflopBets))
            writeFile.write('\n')
        if (numBoardCards >= 4):
            turnRanking = Simulation.simulateOld(myHand, boardCards[0:4], 4,
                                                 100)
            writeFile.write(str(turnRanking) + "," + ','.join(turnBets))
            writeFile.write('\n')
        if (numBoardCards == 5):
            riverRanking = Simulation.simulateOld(myHand, boardCards[0:5], 5,
                                                  100)
            writeFile.write(str(riverRanking) + "," + ','.join(riverBets))
            writeFile.write('\n')
Exemple #3
0
 def updateHandRanking(self):
     if(self.cardsChanged == True):
         if(self.numBoardCards == 0): #preflop
             self.pokeriniRank = Pokerini.pokeriniLookup(self.myHand, pokeriniDict)
             self.calculatePreflopBetLimit()
         if(self.numBoardCards >= 3):#postflop
             #self.simulationWinChance = Simulation.simulate(self.myHand, self.boardCards, self.numBoardCards, 200, handEvalDict, translationDict)
             self.simulationWinChance = Simulation.simulateOld(self.myHand, self.boardCards, self.numBoardCards, self.numSimulations)
     self.cardsChanged = False
Exemple #4
0
iAgreeWithBet = False
opponentAgreesWithBet = False
numBoardCards = 0
boardCards = []

opponentRound0Folds = 0
opponentRound1Folds = 0
opponentRound2Folds = 0
opponentRound3Folds = 0

preflopBets = []
postflopBets = []
turnBets = []
riverBets = []

d = Pokerini.pokeriniInitialise()


#If both players agree on bet, moves bet to pot
def updatePot():
    global iAgreeWithBet, opponentAgreesWithBet, myPot, myBet, opponentPot, opponentBet
    if (iAgreeWithBet and opponentAgreesWithBet):
        myPot = myPot + myBet
        myBet = 0
        opponentPot = opponentPot + opponentBet
        opponentBet = 0
        iAgreeWithBet = False
        opponentAgreesWithBet = False


#handles actions performed between GetAction packets
Exemple #5
0
        meanSimulations = self.totalNumSimulations / (self.handId -1)
        print "timeLeftPerHand: ", timeLeftPerHand
        print "timePerHand", timePerHand
        if self.handId > self.totalNumHands - 20:
            safetyFactor = 0.60
        elif self.handId > self.totalNumHands - 60:
            safetyFactor = 0.80
        else:
            safetyFactor = 0.95
        return int(meanSimulations * safetyFactor * ( timeLeftPerHand / timePerHand ))

if __name__ == '__main__':
    start =time.time()
    bot = Player()
    #bot.loadParametersFromFile()
    pokeriniDict = Pokerini.pokeriniInitialise()
    #PP.processDumpFile()
    #evalTable.createEvalCSV()

    '''
    handEvalDict = evalTable.loadHandEval()
    translationDict = evalTable.loadTranslationDict()
    '''

    parser = argparse.ArgumentParser(description='A Pokerbot.', add_help=False, prog='pokerbot')
    parser.add_argument('-h', dest='host', type=str, default='localhost', help='Host to connect to, defaults to localhost')
    parser.add_argument('port', metavar='PORT', type=int, help='Port on host to connect to')
    args = parser.parse_args()

    # Create a socket connection to the engine.
    print 'Connecting to %s:%d' % (args.host, args.port)
Exemple #6
0
def parseHand(words, length):
    if length == 1:
        return [parseCard(words[1:-1])]
    hand = []
    for x in range(0, length):
        if x == 0:
            hand.append(parseCard(words[x][1:]))
            continue
        if x == length - 1:
            hand.append(parseCard(words[x][:-1]))
            continue
        hand.append(parseCard(words[x]))
    return hand


pokeriniDict = Pokerini.pokeriniInitialise()

print "*********************************************************************"

teamID = {}

for fn in os.listdir('hands'):
    #print (fn)
    #Pokerini initialised
    #Open and process the file
    #f = open('process.txt', 'r')
    if fn == ".DS_Store": continue

    print fn

    f = open("hands/" + fn, 'r')
iAgreeWithBet = False
opponentAgreesWithBet = False
numBoardCards = 0
boardCards = []

opponentRound0Folds = 0
opponentRound1Folds = 0
opponentRound2Folds = 0
opponentRound3Folds = 0

preflopBets = []
postflopBets = []
turnBets = []
riverBets = []

d = Pokerini.pokeriniInitialise()


    #If both players agree on bet, moves bet to pot
def updatePot():
    global iAgreeWithBet, opponentAgreesWithBet, myPot, myBet, opponentPot, opponentBet
    if(iAgreeWithBet and opponentAgreesWithBet):
        myPot = myPot + myBet
        myBet = 0
        opponentPot = opponentPot + opponentBet
        opponentBet = 0
        iAgreeWithBet = False
        opponentAgreesWithBet = False

#handles actions performed between GetAction packets
def parsePerformedAction(performedAction, writeFile):
def parseHand(words, length):
    if length == 1:
        return [parseCard(words[1:-1])]
    hand = []
    for x in range(0,length):
        if x == 0:
            hand.append(parseCard(words[x][1:]))
            continue
        if x == length-1:
            hand.append(parseCard(words[x][:-1]))
            continue
        hand.append(parseCard(words[x]))
    return hand

pokeriniDict = Pokerini.pokeriniInitialise()

#Pokerini initialised

#Open and process the file
#f = open('process.txt', 'r')
f = open("hands/" + fn, 'r')
x = f.readlines()

#Split the lines into each hand
start = 0
end = 0
hand = 1
handsDict = {}
lineNum = len(x)
for i in range(0,lineNum):
def parseHand(words, length):
    if length == 1:
        return [parseCard(words[1:-1])]
    hand = []
    for x in range(0,length):
        if x == 0:
            hand.append(parseCard(words[x][1:]))
            continue
        if x == length-1:
            hand.append(parseCard(words[x][:-1]))
            continue
        hand.append(parseCard(words[x]))
    return hand

pokeriniDict = Pokerini.pokeriniInitialise()

print "*********************************************************************"


teamID = {}

for fn in os.listdir('hands'):
    #print (fn)
    #Pokerini initialised
    #Open and process the file
    #f = open('process.txt', 'r')
    if fn == ".DS_Store": continue

    print fn