def play_hand(self, feedback_file_name, action): date_time = datetime.datetime.now().strftime("%m-%d-%y %H:%M:%S") deck = Deck() deck.create() deck.shuffle() hand = Hand() hand.get_hand(deck) hand.order_hand() hand_type = hand.hand_type() position = Position() position.current_position(self.num_players) position_min = position.min_open() r = Range(self.hand_range) correct_decision, hand_percent, total_cards = r.correct_decision( hand_type, position_min) min_open_hand = r.min_open_card(position_min) decision = Decision(action).decision() if self.show_feedback: if decision == correct_decision: feedback = "Correct" # report feedback self.score += 1 else: feedback = "Incorrect" # report feedback feedback_file_name.save_hand(self.hand_num, date_time, self.hand_range, feedback, position, position_min, min_open_hand, hand, hand_type, hand_percent, decision, correct_decision, self.score) self.hand_num += 1 else: self.hand_num += 1 return self.hand_num
def test_min_open(self): """ Since we are working with decimals/fractions not all numbers can be represented. Will leave all formatting for the gui so the end user will see it. These are just approximations.""" b = Position('Button') p = int(b.min_open() * 100) p /= 100 assert p == 0.33 co = Position('Cut Off') p = int(co.min_open() * 100) p /= 100 assert p == 0.25 hj = Position('High Jack') p = int(hj.min_open() * 100) p /= 100 assert p == 0.20 lj = Position('Low Jack') p = int(lj.min_open() * 100) p /= 100 assert p == 0.16 b5o = Position('5 Off Button') p = int(b5o.min_open() * 100) p /= 100 assert p == 0.14 b6o = Position('6 Off Button') p = int(b6o.min_open() * 100) p /= 100 assert p == 0.12 b7o = Position('7 Off Button') p = int(b7o.min_open() * 100) p /= 100 assert p == 0.11 b8o = Position('8 Off Button') p = int(b8o.min_open() * 100) p /= 100 assert p == 0.10
def play_hand(self, feedback_file_name): date_time = datetime.datetime.now().strftime("%m-%d-%y %H:%M:%S") print("Hand number: " + str(self.hand_num)) deck = Deck() deck.create() deck.shuffle() hand = Hand() hand.get_hand(deck) print(hand) hand.order_hand() hand_type = hand.hand_type() position = Position() position.current_position(self.num_players) print(position) position_min = position.min_open() r = Range(self.hand_range) correct_decision, hand_percent, total_cards = r.correct_decision( hand_type, position_min) # Leaving the following several print statements for reference in case someone else isn't that familiar with hand range calculations. # print(correct_decision) # print(hand_percent) # print(total_cards) # To confirm the hand percentage is correct: total_cards / 1326 = hand_percent min_open_hand = r.min_open_card(position_min) # print(min_open_hand) action = int(input("What is your decision? (4=Open, 6=Fold): ") ) # For faster keyboard input decision = Decision(action).decision() if decision != "stop": if self.show_feedback: if decision == correct_decision: # screen feedback print( "Good job! You should", correct_decision, "because you want to play the top {0:.2f}".format( position_min * 100) + "% of your range; which ends at " + str(min_open_hand) + ".\n" + str(hand) + "is in the top {0:.2f}".format(hand_percent * 100) + "% of starting hands for the " + self.hand_range + " range.") feedback = "Correct" # report feedback self.score += 1 else: print( "Sorry, you should", correct_decision, "because you want to play the top {0:.2f}".format( position_min * 100) + "% of your range; which ends at " + str(min_open_hand) + ".\n" + str(hand) + "is in the top {0:.2f}".format(hand_percent * 100) + "% of starting hands for the " + self.hand_range + " range.") feedback = "Incorrect" # report feedback feedback_file_name.save_hand(self.hand_num, date_time, self.hand_range, feedback, position, position_min, min_open_hand, hand, hand_type, hand_percent, decision, correct_decision, self.score) self.hand_num += 1 print("Score: " + str(self.score) + "\n") else: self.hand_num += 1 print() else: print("Thanks for playing.") return action