Let's make draw poker with ruby ~ Preparation ~


@paraizo2424 Implementing poker little by little in Ruby Part 1

When I saw this, I thought it was a good challenge, so I made a comment. Do I have the technical ability to give advice? Isn't it still the side to receive advice?

How do you design and implement it when you think about it? While reorganizing I decided to make it because I was staring at myself

I use ruby for work, but when I first joined the company, what was ruby? Because it was a level that I only knew about the name I hope I can look back on that as well.

First, organize the rules of poker

Reference: https://playingcards.jp/game_rules/drawpoker_rules.html

Card used

--Are there 1 ~ 13 + jokers for all suits? --This time I will go without joker ――Maybe I will add it?


--2..7 people


  1. Distribute 5 cards from the deck to each player --Each player does not show 5 cards around
  2. Each player can exchange as many cards as he / she wants only once.
  3. Show each player's hand, and the victory or defeat is decided according to the combination (role) of the hand ――Originally, there is a bet here, and it will be a game to get this ――This time, I will not bet for the time being


――It will be a strong role in order from the top below --Royal Straight Flush --Align 10, J, Q, K, A with the same mark --Straight flush ――With the same mark, 5 numbers are consecutive --Four Card --There are 4 cards with the same number


――Will you reveal the discarded card? --It seems that it will not be released ――What is the comparison between full houses? --In the case of full houses, the rank of a set of 3 cards ――How do you compare straights? --Compare with the strongest card --Straight tricks -> Note: Only Ace can be used as the top or bottom rank 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 screens etc. and the purpose is to design and implement ruby classes, it will be executed on the console. ――If you don't make all players exchange, it will be difficult to play with the first 5 cards, so all players will be controlled by the performer (meaning of the game w).

Determining the mounting environment

--Use ruby 2.6.5 --Use test-unit ――I usually use only rspec at work, so I'll try to touch it.

Arrangement of characters

I don't know how to express it properly, but I will try to divide it into things and things that are not things (= concept).




--Deck --All cards --Hand --Each player's hand (5 cards) dealt from the deck --Role --Combination in your hand --Has the following --Type of role --Strength in the role



I'm going to make it from now on, so I just made it empty. from here. I'm looking forward to it.


Let's make draw poker with ruby-test-unit preparation-

Recommended Posts

Let's make draw poker with ruby ~ Preparation ~
Let's make draw poker with ruby-Implementation 4 (Deck)-
Let's make draw poker with ruby-Implementation 3 (player)-
Let's make draw poker with ruby-Implementation 2 (role)-
Let's make a smart home with Ruby!
Let's make a LINE Bot with Ruby + Sinatra --Part 2
Let's make a LINE Bot with Ruby + Sinatra --Part 1
Make electronic music with randomness with Ruby
Let's use Amazon Textract with Ruby
Make a typing game with ruby
Make Ruby Kurosawa with Ruby (Ruby + LINE Messaging API)
Let's make a Christmas card with Processing!
Let's make an error screen with Rails
Let's make a search function with Rails (ransack)
How to make LINE messaging function made with Ruby
[Java basics] Let's make a triangle with a for statement
Make Nginx of CentOS8 SSL compatible with Let's Encrypt
Install Ruby 3.0.0 with asdf
Let's make Rails-like (View)
Getting Started with Ruby
Let's scrape with Java! !!
11th, Classification with Ruby
Evolve Eevee with Ruby
Let's write how to make API with SpringBoot + Docker from 0
Let's make something that can manage events using fullcalendar. ① Preparation
Learning Ruby with AtCoder 13 How to make a two-dimensional array
Let's make a simple API with EC2 + RDS + Spring boot ①