Implementing poker little by little in Ruby Part 3

Previous article

Part 1Part 2

Judgment of the role

The role is Royal Straight> Straight Flush> Four Cards> Full House> Flush> Straight> Three Cards> Two Pairs> One Pair> High Cards (No role, commonly known as pigs) It becomes the strength of the order. For example, if the winning combination is a four-card, it is not necessary to determine the winning combination (three cards, one pair). Therefore, we will judge from the strong role.

Is it better to judge from a weak role ??

[Probability of role](https://ja.wikipedia.org/wiki/%E3%83%9D%E3%83%BC%E3%82%AB%E3%83%BC%E3%83%BB%E3 % 83% 8F% E3% 83% B3% E3% 83% 89% E3% 81% AE% E4% B8% 80% E8% A6% A7 # 5% E6% 9E% 9A% E3% 81% AE% E3 % 81% A8% E3% 81% 8D% E3% 81% AE% E7% A2% BA% E7% 8E% 87) The combined probability of getting a pair or high card is about 92%. Since it is "focused on moving", let's consider it later.

Whose behavior is it to judge the role ??

Mahjong will judge the role and calculate the score by itself, so let's say that poker also judges the role by himself.

Part 3 flow

The player determines what his role is player.judge (Whether all hands have the same mark) same_suit? (Is your hand lined up?) Count_up? (How many pairs, three cards, four cards are in your hand) count_pair Player announces his role player.show Game over

code

https://github.com/paraizo2424/poker_game/commit/0342813bd1fccd3183e1111ad48bf9b00106e2ef

next time

Part 4 (currently under construction)

Recommended Posts

Implementing poker little by little in Ruby Part 2
Implementing poker little by little in Ruby Part 1
Implementing poker little by little in Ruby Part 3
Implementing poker little by little in Ruby Part 1
Implementing poker little by little in Ruby Part 4
Implementing poker little by little in Ruby Part 3
Heavy in Ruby! ??
Write a test by implementing the story of Mr. Nabeats in the world with ruby
Output triangle in Ruby
Variable type in ruby
Fast popcount in Ruby
Heavy in Ruby! ??
Write a test by implementing the story of Mr. Nabeats in the world with ruby
Output triangle in Ruby
Variable type in ruby
Fast popcount in Ruby