Skip to content

Commit

Permalink
Merge pull request #1 from chuchuhao/master
Browse files Browse the repository at this point in the history
fix f-string can not run under python 3.5
  • Loading branch information
ihendley authored Mar 3, 2018
2 parents dcd3098 + d4eb101 commit c9cdcee
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions go.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@
p2_class = evaluator.get_rank_class(p2_score)

# or get a human-friendly string to describe the score
print(f"Player 1 hand rank = {p1_score} {evaluator.class_to_string(p1_class)}")
print(f"Player 2 hand rank = {p2_score} {evaluator.class_to_string(p2_class)}")
print("Player 1 hand rank = {} {evaluator.class_to_string(p1_class)}".format(p1_score))
print("Player 2 hand rank = {} {evaluator.class_to_string(p2_class)}".format(p2_score))

# or just a summary of the entire hand
hands = [player1_hand, player2_hand]
Expand Down
2 changes: 1 addition & 1 deletion treys/card.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ def int_to_pretty_str(card_int):

r = Card.STR_RANKS[rank_int]

return f"[{r}{s}]"
return "[{}{}]".format(r,s)

@staticmethod
def print_pretty_card(card_int):
Expand Down
14 changes: 7 additions & 7 deletions treys/evaluator.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def hand_summary(self, board, hands):

for i in range(len(stages)):
line = "=" * line_length
print(f"{line} {stages[i]} {line}")
print("{} {} {}".format(line,stages[i],line))

best_rank = 7463 # rank one worse than worst hand
winners = []
Expand All @@ -153,7 +153,7 @@ def hand_summary(self, board, hands):
rank_class = self.get_rank_class(rank)
class_string = self.class_to_string(rank_class)
percentage = 1.0 - self.get_five_card_rank_percentage(rank) # higher better here
print(f"Player {player + 1} hand = {class_string}, percentage rank among all hands = {percentage}")
print("Player {} hand = {}, percentage rank among all hands = {}".format(player + 1, class_string, percentage))

# detect winner
if rank == best_rank:
Expand All @@ -166,16 +166,16 @@ def hand_summary(self, board, hands):
# if we're not on the river
if i != stages.index("RIVER"):
if len(winners) == 1:
print(f"Player {winners[0] + 1} hand is currently winning.\n")
print("Player {} hand is currently winning.\n".format(winners[0] + 1))
else:
print(f"Players {[x + 1 for x in winners]} are tied for the lead.\n")
print("Players {} are tied for the lead.\n".format([x + 1 for x in winners]))

# otherwise on all other streets
else:
hand_result = self.class_to_string(self.get_rank_class(self.evaluate(hands[winners[0]], board)))
print()
print(f"{line} HAND OVER {line}")
print("{} HAND OVER {}".format(line, line))
if len(winners) == 1:
print(f"Player {winners[0] + 1} is the winner with a {hand_result}\n")
print("Player {} is the winner with a {}\n".format(winners[0] + 1, hand_result))
else:
print(f"Players {winners} tied for the win with a {hand_result}\n")
print("Players {} tied for the win with a {}\n".format(winners,hand_result))

0 comments on commit c9cdcee

Please sign in to comment.