def bid(self, currentBids):
        """Invoked for each bot when it has an option of bidding."""  
        highestCurrentBid = BiddingUtilities.highest_current_bid(currentBids)
        
        potentialBid = Bid(self.identifier, None, None, 'pass')
        if self.handValue >= 10 and not(any(filter(lambda x: x.bidType != 'pass', currentBids))):
            longestSuit = max(self.suitLengths.items(), key=lambda x: x[1])[0]
            longestSuit = 'nt'            
            return Bid(self.identifier, 1, longestSuit, 'bid')

        if self.handValue >= 11 and not BiddingUtilities.has_partnership_bid(currentBids):            
            longestSuit = max(self.suitLengths.items(), key=lambda x: x[1])[0]
            longestSuit = 'nt'
            potentialBid = Bid(
                self.identifier, 
                BiddingUtilities.next_legal_bid(highestCurrentBid, longestSuit), 
                longestSuit, 
                'bid')
        
        if len(currentBids) > 2 and currentBids[-2].bidValue is not None and currentBids[-2].bidValue < 2:
            if self.handValue > 6 and currentBids[-2].bidSuit is not None and self.suitLengths[currentBids[-2].bidSuit] > 2:
                potentialBid = Bid(
                    self.identifier, 
                    BiddingUtilities.next_legal_bid(highestCurrentBid, currentBids[-2].bidSuit), 
                    currentBids[-2].bidSuit, 
                    'bid')
                
        return potentialBid
    def bid(self, currentBids):
        """Invoked for each bot when it has an option of bidding."""
        highestCurrentBid = BiddingUtilities.highest_current_bid(currentBids)

        potentialBid = Bid(self.identifier, None, None, 'pass')
        if self.handValue >= 10 and not (any(
                filter(lambda x: x.bidType != 'pass', currentBids))):
            longestSuit = max(self.suitLengths.items(), key=lambda x: x[1])[0]
            longestSuit = 'nt'
            return Bid(self.identifier, 1, longestSuit, 'bid')

        if self.handValue >= 11 and not BiddingUtilities.has_partnership_bid(
                currentBids):
            longestSuit = max(self.suitLengths.items(), key=lambda x: x[1])[0]
            longestSuit = 'nt'
            potentialBid = Bid(
                self.identifier,
                BiddingUtilities.next_legal_bid(highestCurrentBid,
                                                longestSuit), longestSuit,
                'bid')

        if len(currentBids) > 2 and currentBids[
                -2].bidValue is not None and currentBids[-2].bidValue < 2:
            if self.handValue > 6 and currentBids[
                    -2].bidSuit is not None and self.suitLengths[
                        currentBids[-2].bidSuit] > 2:
                potentialBid = Bid(
                    self.identifier,
                    BiddingUtilities.next_legal_bid(highestCurrentBid,
                                                    currentBids[-2].bidSuit),
                    currentBids[-2].bidSuit, 'bid')

        return potentialBid
Exemple #3
0
    def legal_bid(currentBid, bids, playerID, partnerID):
        lastValueBid = BiddingUtilities.highest_current_bid(bids)
        lastNonPassBid = BiddingUtilities.last_nonpass_bid(bids)

        if currentBid.bidValue is not None and (currentBid.bidValue > 7 or currentBid.bidValue < 1):
            return False
        
        if currentBid.bidType != 'bid' and (currentBid.bidValue is not None or currentBid.bidSuit is not None):
            return False
        
        if currentBid.bidType == 'bid':
            return lastValueBid is None or currentBid > lastValueBid
        
        if currentBid.bidType == 'double':
            return (lastNonPassBid is not None 
                and lastNonPassBid.playerID not in [playerID, partnerID]
                and lastNonPassBid.bidType == 'bid')
        
        if currentBid.bidType == 'redouble':
            return (lastNonPassBid is not None and 
                lastNonPassBid.bidType == 'double' and
                lastNonPassBid.playerID not in [playerID, partnerID])
                
        # pass is always legal
        return True
Exemple #4
0
    def legal_bid(currentBid, bids, playerID, partnerID):
        lastValueBid = BiddingUtilities.highest_current_bid(bids)
        lastNonPassBid = BiddingUtilities.last_nonpass_bid(bids)

        if currentBid.bidValue is not None and (currentBid.bidValue > 7
                                                or currentBid.bidValue < 1):
            return False

        if currentBid.bidType != 'bid' and (currentBid.bidValue is not None
                                            or currentBid.bidSuit is not None):
            return False

        if currentBid.bidType == 'bid':
            return lastValueBid is None or currentBid > lastValueBid

        if currentBid.bidType == 'double':
            return (lastNonPassBid is not None
                    and lastNonPassBid.playerID not in [playerID, partnerID]
                    and lastNonPassBid.bidType == 'bid')

        if currentBid.bidType == 'redouble':
            return (lastNonPassBid is not None
                    and lastNonPassBid.bidType == 'double'
                    and lastNonPassBid.playerID not in [playerID, partnerID])

        # pass is always legal
        return True
Exemple #5
0
    def bid(self, currentBids):
        """Invoked for each bot when it has an option of bidding."""
        highestCurrentBid = BiddingUtilities.highest_current_bid(currentBids)

        potentialBid = Bid(self.identifier, None, None, 'pass')

        minOpenPoints = 10
        openBid = 1
        if self._ourState.belowTheLine >= 70:
            minOpenPoints = 5
        elif self._ourState.belowTheLine >= 40:
            minOpenPoints = 8
            openBid = 2

        # enough points to open and no previous bids
        if self.handValue >= minOpenPoints and not (any(
                filter(lambda x: x.bidType != 'pass', currentBids))):
            longestSuit = max(self.suitLengths.items(), key=lambda x: x[1])[0]
            longestSuit = 'nt'
            potentialBid = Bid(self.identifier, openBid, longestSuit, 'bid')

        # enough points to open and previous bids from other partnership
        if self.handValue >= 11 and not BiddingUtilities.has_partnership_bid(
                currentBids):
            highestCurrentBid = BiddingUtilities.highest_current_bid(
                currentBids)
            longestSuit = max(self.suitLengths.items(), key=lambda x: x[1])[0]
            longestSuit = 'nt'
            potentialBid = Bid(
                self.identifier,
                max(
                    BiddingUtilities.next_legal_bid(highestCurrentBid,
                                                    longestSuit), openBid),
                longestSuit, 'bid')

        # raise partner's bid
        if len(currentBids) > 2 and currentBids[
                -2].bidValue is not None and currentBids[-2].bidValue < 2:
            if self.handValue > 6 and currentBids[
                    -2].bidSuit is not None and self.suitLengths[
                        currentBids[-2].bidSuit] > 2:
                potentialBid = Bid(
                    self.identifier,
                    BiddingUtilities.next_legal_bid(highestCurrentBid,
                                                    currentBids[-2].bidSuit),
                    currentBids[-2].bidSuit, 'bid')

        return potentialBid
 def bid(self, currentBids):
     """Invoked for each bot when it has an option of bidding."""  
     highestCurrentBid = BiddingUtilities.highest_current_bid(currentBids)
     
     potentialBid = Bid(self.identifier, None, None, 'pass')
     
     minOpenPoints = 10
     openBid = 1
     if self._ourState.belowTheLine >= 70:
         minOpenPoints = 5
     elif self._ourState.belowTheLine >= 40:
         minOpenPoints = 8
         openBid = 2
         
     # enough points to open and no previous bids 
     if self.handValue >= minOpenPoints and not(any(filter(lambda x: x.bidType != 'pass', currentBids))):
         longestSuit = max(self.suitLengths.items(), key=lambda x: x[1])[0]
         longestSuit = 'nt'
         potentialBid = Bid(self.identifier, openBid, longestSuit, 'bid')
     
     # enough points to open and previous bids from other partnership
     if self.handValue >= 11 and not BiddingUtilities.has_partnership_bid(currentBids):
         highestCurrentBid = BiddingUtilities.highest_current_bid(currentBids)
         longestSuit = max(self.suitLengths.items(), key=lambda x: x[1])[0]
         longestSuit = 'nt'
         potentialBid = Bid(
             self.identifier, 
             max(BiddingUtilities.next_legal_bid(highestCurrentBid, longestSuit), openBid), 
             longestSuit, 
             'bid')
     
     # raise partner's bid        
     if len(currentBids) > 2 and currentBids[-2].bidValue is not None and currentBids[-2].bidValue < 2:
         if self.handValue > 6 and currentBids[-2].bidSuit is not None and self.suitLengths[currentBids[-2].bidSuit] > 2:
             potentialBid = Bid(
                 self.identifier, 
                 BiddingUtilities.next_legal_bid(highestCurrentBid, currentBids[-2].bidSuit), 
                 currentBids[-2].bidSuit, 
                 'bid')
             
     return potentialBid