@paraizo2424 Implementing poker little by little with Ruby Part 1
When I saw this, I thought that it would be a good challenge, and I commented. Is it technical enough to give advice? Isn’t it still the side to get advice?
Then, how do you design and implement it? While rearranging I thought I’d make it by staring at myself
I use ruby at work. What was ruby when I first joined the company? Because it was a level I only knew about the name I would like to look back with that meaning
First, organize poker rules
- 1~13 in all suits + Joker? -This time I will go without joker -Maybe I will add it?
- Distribute 5 cards from each deck to each player -Each player does not show 5 cards around
- You can exchange your favorite number of cards once for each player order.
- Show each player’s hand and win or lose depending on the hand combination (role) -Originally, there is a bet (payment) here, and it becomes a game to get this. -This time I will not bet for the time being
- It becomes a strong role in order from the following
-Royal straight flush
-Align 10, J, Q, K, A of the same mark
-Five numbers are consecutive with the same mark
-There are 4 cards with the same number
- Full house -Three cards and one pair can be made one by one -Flash -There are 5 cards with the same mark
- straight -5 numbers are consecutive regardless of the mark -(10-J-Q-K-A is straight, but Q-K-A-2-3 is not straight -That is, K and A are continuous, but those containing K-A-2 are not straight) -Three card -There are 3 cards with the same number -Two pair -There are two cards with the same number -One pair -Only one card with the same number
- If two players make the same hand, the card with the strongest part of the hand wins -Strong ranking of cards is A, K, Q, J, 10~2 -The strong ranking of suits is Spade Heart Diamond Clover
- If the cards that make up the part are the same, the card that is not used for the part is stronger
- Will you throw away the discarded card? -It seems that it will not be published
- How do you compare full houses? -For full houses, the rank of a set of 3 cards
- How do you compare straights? -Compare with the strongest card
- Straight trick -> Note: Only Aces can be used as the top or bottom card. The strongest straight is A-K-Q-J-T (ace high) and the weakest straight is 5-4-3-2-A (five high).
Determining the implementation range this time
- Since there are no bets, it is not a continuous game but one game
- Since it is troublesome to create a screen etc. and for the purpose of ruby class design/implementation, it is executed on the console
- I think that it is difficult for the first 5 cards to compete if all players do not exchange, so all players should be controlled by the performer (meaning w)
Implementation environment decision
- Use ruby 2.6.5
- use test-unit -I usually use only rspec at work, so I will touch it so I will touch it
Organization of characters
I don’t know how to express it properly, but try to separate it from the meaning of things and things that are not things (= concept)
- Deck -All cards
- Hand -Each player’s hand dealt from the deck (5)
- Role -Combination in hand -Have the following -Role type -Strength in the role
I’m going to make it from now on, so I just created it empty. from here. Looking forward.