Quote:
Originally Posted by jjshabado
If you're interested in the debate/exercise you could probably post it in this thread and we'll argue a bunch over almost meaningless stuff.
Here's the code in question:
The input is a list of tuples.
[('d', 4), ('d', 1), ('d', 8), ('c', 2), ('d', 7), ('h', 4), ('s', 6)]
The code breaks apart the tuples into ranks and suits.
['d', 'd', 'd', 'c', 'd', 'h', 's']
[1, 2, 4, 4, 6, 7, 8]
Then weighs the hands according to rank.
This particular block of code needs a lot of fixing (and will become longer) but that's okay since I'm more concerned about getting the routed out functions correct so they don't trip over each other (the twoPair and fullHouse is bad, I know). The prints will route to functions later on.
I also forgot to account for ex: straight vs straight who has the highest straight, so I have to add in the high-card functions. They way I'll do this is have the winning hand returned to this function if there is a True, else return the whole hand:
Code:
def otherFun(hand)
if x == True:
return True, hand[:-2]
return False, hand
Actually, I'm kind of ashamed of this block of code, it's much messier than the rest of the program, but I think its okay since it is still being built.
Anyways, there should be room to debate this one.
Code:
def evalHand(board):
print(board)
suits = []
ranks = []
for i in board:
suits.append(i[0])
ranks.append(i[1])
print(suits)
print(sorted(ranks))
boolQuad = quads(ranks)
if boolQuad == True:
print('quads')
#boolFull = full(ranks)
boolFlush = flush(suits)
if boolFlush == True:
boolStraight = straight(ranks)
if boolStraight == True:
print('straigh flush')
print('flush')
boolStraight = straight(ranks)
if boolStraight == True:
print('straight')
boolTriple = triple(ranks)
if boolTriple == True:
if boolPair == True:
print('full house')
print('three of a kind')
boolPair = pair(ranks)
if boolPair == True:
## if boolPair == True:
## print('two pair')
print('one pair')
boolHighCard = highCard(ranks)
print(boolHighCard, ' high')