Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
自作ゲームに使えるgem作ってみた
Search
新卒えんじにゃ
November 29, 2025
70
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
自作ゲームに使えるgem作ってみた
tokyuruby kaigi
新卒えんじにゃ
November 29, 2025
More Decks by 新卒えんじにゃ
See All by 新卒えんじにゃ
TokyuRubyKaigi 基調講演
sinsotu_enjinya
1
62
えっ!?gemって自作できるんですか?
sinsotu_enjinya
0
520
Featured
See All Featured
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
128
56k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
141
35k
Money Talks: Using Revenue to Get Sh*t Done
nikkihalliwell
0
500
Jess Joyce - The Pitfalls of Following Frameworks
techseoconnect
PRO
1
420
Navigating the moral maze — ethical principles for Al-driven product design
skipperchong
2
570
Building Adaptive Systems
keathley
44
3.2k
Conquering PDFs: document understanding beyond plain text
inesmontani
PRO
4
3.1k
Building Applications with DynamoDB
mza
96
7.2k
Noah Learner - AI + Me: how we built a GSC Bulk Export data pipeline
techseoconnect
PRO
0
440
How People are Using Generative and Agentic AI to Supercharge Their Products, Projects, Services and Value Streams Today
helenjbeal
1
330
Building a Scalable Design System with Sketch
lauravandoore
464
34k
Automating Front-end Workflow
addyosmani
1369
210k
Transcript
自作ゲームに使える gem作ってみた! 新卒えんじにゃ
iOS/Androidゲームアプリ Railsサーバーエンジニア Neko_gem 先月のKaigi on Rails事後勉強会にて登壇 https://speakerdeck.com/sinsotu_enjinya/etu-gemtutezi-zuo- dekirundesuka 長所:努力できる 短所:それ以外全部
最近のやらかし:卵3パック購入
無職!!!!!!!
None
ゲームエンジニアが作った! ソシャゲガチャgem
新卒の元ゲームエンジニアが 作ったソシャゲガチャgem
ソシャゲgem Case 1 Social-Game-Kit 1
コンセプト Case 1 Social-Game-Kit 1 ⚫ 誰でもガチャシステムが作れる - ガチャは重くなりがち -
セオリーの実装がわからない ⚫ 通常のwebアプリでも気軽に使える - 忘年会の催し物 - 新年おみくじ
実際の機能 Case 2 Social-Game-Kit 2
重み計算とは? Case 2 Social-Game-Kit 2 →確率で計算すればいいんだ!
重み計算とは? Case 2 Social-Game-Kit 2 カード.each do |カード, カード数| 抽選確率
= Aのカード/トータルカード # ここで毎回確率を計算 # しかも出る確率で毎回抽選を掛ける end
重み計算とは? Case 2 Social-Game-Kit 2 滅茶苦茶重くなる!
重み計算とは? Case 2 Social-Game-Kit 2 1.(確率表的なものを作る) 2.確立の計算をする(カード毎) 3.浮動小数点処理を頑張る(カード毎)
重み計算とは? Case 2 Social-Game-Kit 2 浮動小数点処理 - メモリ爆発の原因 - ガチャは課金と密接に紐づいている
- 確率計算がおかしいと訴訟問題にも →→リスクがある上に重い
重み計算とは? Case 2 Social-Game-Kit 2 A:重み 1(区間 0〜0) B:重み 3(区間
1〜3) C:重み 6(区間 4〜9) 合計:10 0 →A 1〜3→B 4〜9→C
重み計算とは? Case 2 Social-Game-Kit 2 1.正の数を足し算 2.rand1回と比較1回で処理は終わり →正の整数の足し算=安全 →新しいカードが増えても軽い
お手軽に誰でもガチャ実装! Case 3 Social-Game-Kit 3
Social-Game-Kit 3
お手軽に誰でもガチャ実装! Case 3 Social-Game-Kit 3 https://github.com/NYUWAMOCHI/sgk_demo
Railsエンジニアとして https://x.com/engn_nnnaa ポートフォリオを持って 徘徊中!!!!!
具体的な間違い実装 Case 3 Social-Game-Kit 3 ゲーム会社のマスタ管理: id 1 ねこにゃん id
2 いぬにゃん ~~~~~~~~~~~~~~~~ id 100 イベントねこにゃん id 101 イベントいぬにゃん
具体的な間違い実装 Case 3 Social-Game-Kit 3 @draw_cards= [] - ハッシュではなく、配列で実装 -
id:3からid:99までにnilが挿入される - メモリのヒープ領域が全部確保される →メモリ大爆発
具体的な間違い実装 Case 3 Social-Game-Kit 3 @draw_cards= [] …重み計算処理… @draw_cards[@draw_table[card_index].id] =
@draw_table[card_index]