Exemple #1
0
    def verify(self, input):
        """
            Accept or reject the previous player's bet
        """
        prevBet = input.getPrevBet()
        prevQty = prevBet[0]
        prevDie = prevBet[1]
        myQty = input.getYourDice()[prevDie]
        totalDiceInGame = input.getTotalDice()
        myTotalDice = input.getYourTotalDice()

        # calculate odds of bet
        odds = atleast(prevQty - myQty, totalDiceInGame - myTotalDice)
        # what would be my next bet?
        myNextBetQty, myNextBetDie = self.bet(input.getPrevBet(),
                                              input.getYourHighestDice(),
                                              input.getTotalDice(),
                                              input.getYourTotalDice())
        # calculate odds of my next bet
        myNextBetDiceQty = input.getYourDice()[myNextBetDie]
        oddsOfMyNextBet = atleast(myNextBetQty - myNextBetDiceQty,
                                  totalDiceInGame - myTotalDice)
        # if my future odds are less likely than challenging this bet, challenge it
        oddsOfMeWinningIfIChallenge = 1 - odds
        acceptBet = oddsOfMeWinningIfIChallenge < oddsOfMyNextBet

        #acceptOrReject = "accept" if acceptBet else "reject"
        #print(f"{self.name} will {acceptOrReject} last bet of {prevQty} {prevDie+1}'s because it's {round(odds*100)}% likely given that there's {input.getTotalDice()} total dice and I have {myQty} {prevDie+1}'s.")

        return acceptBet
Exemple #2
0
    def bet(self, prevBet, myHighestDice, totalDice, myTotalDice):
        """
            Make a bet with the parameters exploded
        """
        # get previous player's bet
        prevQty, prevDie = prevBet

        # get my die with highest quantity
        myHighestQty, myHighestDie = myHighestDice

        # what's my highest safe bet?
        myHighestSafeQty = myHighestQty
        while atleast((myHighestSafeQty - myHighestQty) + 1,
                      totalDice - myTotalDice) > self.safeOddsToBet:
            myHighestSafeQty += 1

        # if my highest safe bet is higher than previous qty, bet it
        if (myHighestSafeQty > prevQty):
            return [myHighestSafeQty, myHighestDie]
        # if my highest safe qty is the same as the previous qty but mine is a higher die, bet it
        elif (myHighestSafeQty == prevQty and myHighestDie > prevDie):
            return [myHighestSafeQty, myHighestDie]
        # if I can go up to 6 and bet same quantity, do that
        elif (prevDie < 5):
            return [prevQty, 5]
        # if my highest qty + 1 is higher than previous qty, bet it
        elif ((myHighestQty + 1) > prevQty):
            return [myHighestQty + 1, myHighestDie]
        # else stay at same die and increase quantity
        else:
            return [prevQty + 1, prevDie]
Exemple #3
0
    def onVerify(self, correct, belived, input):
        '''Called after you verify a claim when game in training mode (implement me!)

            Parameters
            ----------
                input: PlayInput
                correct: bool (did they tell the truth)
                belived: bool (wether you called them out)
        '''

        self.setup(input)
        arr = []
        for num in np.append(
                np.array(self.Maxs + [
                    len(input.players),
                    input.getTotalDice(),
                    atleast(input.getBetHistory()[-1, 0], input.getTotalDice())
                ]), input.getYourDice()):
            arr.append([num])

        optimizer = tf.train.GradientDescentOptimizer(0.01)

        if correct != belived:
            if self.sess.run(self.out, {self.FullIn: arr})[0] > .5:
                loss = (self.out - 1)**2
            else:
                loss = self.out**2
        else:
            if self.sess.run(self.out, {self.FullIn: arr})[0] > .5:
                loss = self.out**2
            else:
                loss = (self.out - 1)**2
        train = optimizer.minimize(loss)
        _, loss_value = self.sess.run((train, loss))
Exemple #4
0
 def getOdds(self, betQty, betDie, myQty, totalDiceInGame, myTotalDice):
     """
         Return the probability that there's at least betQty of a die out of totalDice dice
         -------
         float (0-1)
     """
     qty = betQty - myQty
     total = totalDiceInGame - myTotalDice
     return atleast(qty, total)
Exemple #5
0
    def verify(self, input):
        self.setup(input)

        arr = []
        for num in np.append(
                np.array(self.Maxs + [
                    len(input.players),
                    input.getTotalDice(),
                    atleast(input.getBetHistory()[-1, 0], input.getTotalDice())
                ]), input.getYourDice()):
            arr.append([num])

        if self.sess.run(self.out, {self.FullIn: arr})[0] > .9:
            return True
        else:
            return False
Exemple #6
0
 def getOdds(this, move, input):
     return atleast(move[0] - input.getYourDice()[move[1]],
                    input.getTotalDice() - input.getYourTotalDice())
Exemple #7
0
 def verify(self, input):
     return atleast(input.getBetHistory()[-1, 0],
                    input.getTotalDice()) < .75