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
64
えっ!?gemって自作できるんですか?
sinsotu_enjinya
0
530
Featured
See All Featured
AI Search: Implications for SEO and How to Move Forward - #ShenzhenSEOConference
aleyda
1
1.4k
The Hidden Cost of Media on the Web [PixelPalooza 2025]
tammyeverts
2
520
Leveraging Curiosity to Care for An Aging Population
cassininazir
1
530
RailsConf 2023
tenderlove
30
1.6k
How STYLIGHT went responsive
nonsquared
100
6.3k
From π to Pie charts
rasagy
1
400
The Spectacular Lies of Maps
axbom
PRO
1
1.1k
Efficient Content Optimization with Google Search Console & Apps Script
katarinadahlin
PRO
1
920
Leveraging LLMs for student feedback in introductory data science courses - posit::conf(2025)
minecr
1
430
Mobile First: as difficult as doing things right
swwweet
225
10k
Crafting Experiences
bethany
1
380
Designing Dashboards & Data Visualisations in Web Apps
destraynor
232
55k
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]