2010-03-31 13:54:35 +00:00
|
|
|
import poker
|
2010-03-30 15:01:13 +00:00
|
|
|
|
2010-03-30 16:03:41 +00:00
|
|
|
if __name__ == '__main__':
|
|
|
|
wins = 0
|
|
|
|
counter = 0
|
|
|
|
with open('poker.txt', 'r') as f:
|
|
|
|
while True:
|
|
|
|
line = f.readline()
|
|
|
|
if not line:
|
|
|
|
break
|
|
|
|
counter = counter + 1
|
|
|
|
cards = line.strip().split()
|
2010-03-31 13:54:35 +00:00
|
|
|
one = poker.Hand(cards[:5])
|
|
|
|
two = poker.Hand(cards[-5:])
|
2010-03-31 20:18:14 +00:00
|
|
|
result = cmp(one, two)
|
2010-03-30 16:03:41 +00:00
|
|
|
if result > 0:
|
|
|
|
wins = wins + 1
|
|
|
|
outcome = 'Player One wins'
|
|
|
|
elif result == 0:
|
|
|
|
outcome = 'Tie'
|
|
|
|
else:
|
|
|
|
outcome = 'Player Two wins'
|
|
|
|
print "Hand #{0}: {1}\n {2}\n {3}".format(
|
|
|
|
counter,
|
|
|
|
outcome,
|
|
|
|
one,
|
|
|
|
two)
|
|
|
|
print "Player one won {0} hands".format(wins)
|