Poker Solver

 


Made dinner for Ally and I last week, linguine with vodka sauce, broccoli, chicken, and cake for desert

In the spare evenings and weekend hours, I continue to do problems posted on projecteuler.com. It's a wonderful website I think I've mentioned before on this blog. The fifty fourth problem involves determining the winner of a hand of poker given two player's hands of five cards each. In person, this would involve both players laying down their cards, announcing their best arrangement (two pair, flush, high card, etc.), and then accepting or not accepting victory based on the other player.

When handling this computationally, every possible outcome must be accounted for in the program. The most difficult part is determining the winner of a tie, It is comparatively simple to say whether five cards can achieve a straight, a flush, or simply a high card; but to determine every tiebreaker is difficult.

The worst way to handle ties is to create a case in the program for every sort of tie. This would be exhaustive and inefficient. Instead, I opted to evaluate ties based on the type of tie reached. If the two players were tied for three of a kind for example, the tie breaker code would determine which value of card each player had three of a kind (queen, 3, jack, etc.), and then immediately determine the winner of the hand of cards. This was a much faster implementation.


The cake I made before being cut


Baptist church near Davis square has this sign up. 


Playing euchre with housemates, my hand had a four of a kind, unfortunately not that great


No comments:

Post a Comment

Time out in RI

  I visited the state of Rhode Island for the first time two weeks ago. It was a great time and I was able to hit up a beach. The weather wa...