コード例 #1
0
ファイル: ChuckTestaStrat.py プロジェクト: oderby/pokerbots
    def decide(self, game, isLAP, score):
        firstToAct = False
        facingBet = False
        facingRaise = False
        canBet = False
        canRaise = False
        comment = "isLap=" + str(isLAP) + ", "

        for la in game.legalActions:
            if la[0] == "BET":
                canBet = True
            if la[0] == "RAISE":
                canRaise = True

        lastAction = game.lastActor.lastActions[-1]
        if game.street == PREFLOP:
            firstToAct = lastAction.type == POST
        else:
            firstToAct = game.me.pip + game.leftOpp.pip + game.rightOpp.pip == 0

        if not firstToAct:
            facingBet = lastAction.type == BET
        facingRaise = not firstToAct and not facingBet

        if firstToAct: comment += "first to act "
        if facingBet: comment += "facing a bet of " + str(game.lastBet) + " "
        if facingRaise: comment += "facing a raise to " + str(game.lastBet) + " "

        prob = random.randint(1,100)
        totalPot = game.pot + game.me.pip + game.leftOpp.pip + game.rightOpp.pip
        if game.street == PREFLOP:
            if firstToAct:
                check = firstToActCutoffs[isLAP][PREFLOP][score-1]
                if prob <= check:
                    move = Move(CALL)
                else:
                    move = Move(RAISE, 6)
            else:
                bin = self.getRaiseBin(game.street, game.lastActor.lastActions[-1])
                if bin == BIN1:
                    if isLAP:
                        raiseAmt = int(3.5*totalPot)
                    else:
                        raiseAmt = int(2.75* totalPot)
                elif bin == BIN2:
                    if isLAP:
                        raiseAmt = int(2.5*totalPot)
                    else:
                        raiseAmt = int(3*totalPot)
                elif bin == BIN3:
                    raiseAmt = int(2.5*totalPot)
                else:
                    raiseAmt = game.me.getAllIn()

                comment += " bin="+str(bin) + " raiseamnt=" + str(raiseAmt)
                r,c = raiseCutoffs[isLAP][game.street][bin][score-1]
                if prob <= r:
                    move = Move(RAISE, raiseAmt)
                elif prob <= c:
                    move = Move(CALL)
                else:
                    move = Move(FOLD)
        else:
            if isLAP:
                betAmt = .8*totalPot
                raiseAmt = max([3*game.lastBet, int(.75*totalPot)])
            else:
                betAmt = .5*totalPot
                raiseAmt = 3*game.lastBet

            if firstToAct:
                check = firstToActCutoffs[isLAP][game.street][score-1]
                if prob <= check:
                    move = Move(CHECK)
                else:
                    move = Move(BET, betAmt)
            elif facingBet:
                bin = self.getBetBin(game.lastActor.lastActions[-1].potAmount)
                comment += " bin="+str(bin) + " betamnt=" + str(betAmt)
                r,c = betCutoffs[isLAP][game.street][bin][score-1]
                if prob <= r:
                    move = Move(RAISE, raiseAmt)
                elif prob <= c:
                    move = Move(CALL)
                else:
                    move = Move(FOLD)
            else:
                bin = self.getRaiseBin(game.street, game.lastActor.lastActions[-1])
                comment += " bin="+str(bin) + " raiseamnt=" + str(raiseAmt)
                r,c = raiseCutoffs[isLAP][game.street][bin][score-1]
                if prob <= r:
                    move = Move(RAISE, raiseAmt)
                elif prob <= c:
                    move = Move(CALL)
                else:
                    move = Move(FOLD)
        move.comment = comment
        return move
コード例 #2
0
ファイル: ChuckTestaStrat.py プロジェクト: oderby/pokerbots
    def getMove(self, game):
        OppEvs = self.getOppEvs(game)
        ev = self.evalHand(game, OppEvs)
        scores = {}
        nump = game.activePlayers

        if ev>blindEVs[nump-2][game.street][2]:
            myBlindEV = GOOD
        elif ev>blindEVs[nump-2][game.street][1]:
            myBlindEV = OK
        elif ev>blindEVs[nump-2][game.street][0]:
            myBlindEV = BAD
        else:
            myBlindEV = AWFUL

        for pname,p in OppEvs.items():
            if p[0] == -1:
                scores[pname] = UNKNOWN
            elif ev>p[0]+p[1]:
                scores[pname] = GOOD
            elif ev>p[0]:
                scores[pname] = OK
            elif ev>p[0]-p[1]:
                scores[pname] = BAD
            else:
                scores[pname] = AWFUL

        maxLeftEV = max([myBlindEV,scores[game.leftOpp.name]])
        if OppEvs[game.leftOpp.name][1]<100:
            maxLeftEV = scores[game.leftOpp.name]
        maxRightEV = max([myBlindEV,scores[game.rightOpp.name]])
        if OppEvs[game.rightOpp.name][1]<100:
            maxLeftEV = scores[game.rightOpp.name]

        print "EV:", ev, "myBlindEV:",myBlindEV, "LEFT EV:", OppEvs[game.leftOpp.name],"-",scores[game.leftOpp.name],"=",scores[game.leftOpp.name], "RIGHT EV:", OppEvs[game.rightOpp.name],"=",scores[game.rightOpp.name], "activePlayers:", game.activePlayers
        if nump == 3:
            score = min([maxLeftEV, maxRightEV])
        else:
            score = maxRightEV
            if not game.rightOpp.active:
                score = maxLeftEV


        tagPlaying = ((not game.leftOpp.isLAP(game) and game.leftOpp.active)
                      or (not game.rightOpp.isLAP(game) and game.rightOpp.active))
        comment = ""
        if score == AWFUL:
            move = Move(CHECK)
        else:
            move = self.decide(game, not tagPlaying, score)
            comment += move.comment
        comment += " score: " + str(score)

        if move.amount is not None:
            move.amount = min([move.amount, game.me.getAllIn()])

        if ACTION_TYPES[move.type] not in [la[0] for la in game.legalActions]:
            print "returned illegal action",move.toString()[:-1],"! in",game.legalActions
            if move.type in [BET,RAISE]:
                move = Move(CALL)
            else:
                move = Move(CHECK)

        move.rightEV = OppEvs[game.rightOpp.name]
        move.leftEV = OppEvs[game.leftOpp.name]
        move.myEV = ev
        move.comment = comment
        return move