Beispiel #1
0
	def __init__(self, _hand=None):
		self.deck = []
		if (_hand):
			self.myHand = _hand
		else:
			self.myHand = bicycle.Hand()
		self.cut = bicycle.Card()
		
		self.averageScore = 0
		self.bestScore = 0
		self.bestCut = bicycle.Card()

		#perm array for fifteencheck
		self.perms = [list(itertools.combinations(range(5), 2)), list(itertools.combinations(range(5), 3)), list(itertools.combinations(range(5), 4))]			
		self.genDeck(self.myHand)
Beispiel #2
0
	def score(self, potentialHand):
		#run check
		#15 check
		#pair/triplet/quad check
		#Nobs check (jack same suit as cut)
		#Flush check
		scores = []
		bScore = 0
		bCut = bicycle.Card()
		#run check
		for cut in self.deck:
			#create the full hand
			fiveHand = bicycle.Hand()
			for x in potentialHand.rawHand:
				fiveHand.rawHand.append(x)
			fiveHand.rawHand.append(cut)
			fiveHand.handSort()
			tmpScore = self.runAndMultiplesCheck(fiveHand)
			tmpScore += self.fifteenCheck(fiveHand)
			#These two are weird because scoring depends on which card is the cut. Thus, we have to pass in both.
			tmpScore += self.nobsCheck(potentialHand.rawHand, cut) 
			tmpScore += self.flushCheck(potentialHand.rawHand, cut)
			scores.append(float(tmpScore))
			if (tmpScore > bScore):
				bScore = tmpScore
				bCut = cut
		output = (statistics.mean(scores), bScore, bCut)
		return(output)
Beispiel #3
0
def calcRandomEntry(num):
    global varHand
    varHand = bicycle.Hand()
    counter = 0
    while counter < num:
        tmpCard = bicycle.Card(_value=random.randint(1, 13),
                               _suit=random.randint(0, 3))
        if not duplicateCheck(tmpCard, varHand):
            varHand.rawHand.append(tmpCard)
            cardEntryWidget.delete(0, END)  #erase text box
            counter += 1
    setHandChanged(True)
Beispiel #4
0
def addCard(event):
    inText = userInput.get().upper()
    if (len(inText) != 2):
        cardEntryWidget.select_range(0, END)
        print("incorrect character count")
    else:
        try:
            suitDict = {'C': 0, 'S': 1, 'D': 2, 'H': 3}
            valDict = {'A': 1, 'T': 10, 'J': 11, 'Q': 12, 'K': 13}
            if inText[0] in valDict:
                tmpCard = bicycle.Card(valDict[inText[0]], suitDict[inText[1]])
            else:
                tmpCard = bicycle.Card(int(inText[0]), suitDict[inText[1]])
            #add the card to varHand
            if (len(varHand.rawHand) < 6):
                if not duplicateCheck(tmpCard, varHand):
                    varHand.rawHand.append(tmpCard)
                    print("added")
                    cardEntryWidget.delete(0, END)  #erase text box
        except (ValueError, KeyError):
            cardEntryWidget.select_range(0, END)
            print("invalid character")
    setHandChanged(True)
Beispiel #5
0
	def genDeck(self, hand):
		for vl in range(1, 14): #value
			for st in range(4): #suit
				for c in hand.rawHand:
					if c.value != vl or c.suit != st:
						self.deck.append(bicycle.Card(vl, st))