Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
GameplayKit, GKRandomSource, GKRandomDistribution
Search
kichikuchi
October 23, 2015
Programming
1
260
GameplayKit, GKRandomSource, GKRandomDistribution
shibuya.swift #1 発表資料
kichikuchi
October 23, 2015
Tweet
Share
More Decks by kichikuchi
See All by kichikuchi
swiftにおける遅延評価
kichikuchi
0
2.8k
tableViewとcoolectionviewのパフォーマンスチューニング
kichikuchi
1
560
AB Tests in Mobile App
kichikuchi
1
1.9k
Other Decks in Programming
See All in Programming
PHPで作るWebSocketサーバー ~リアクティブなアプリケーションを知るために~ / WebSocket Server in PHP - To know reactive applications
seike460
PRO
2
130
急成長期の品質とスピードを両立するフロントエンド技術基盤
soarteclab
0
930
モバイルアプリにおける自動テストの導入戦略
ostk0069
0
110
testcontainers のススメ
sgash708
1
120
責務を分離するための例外設計 - PHPカンファレンス 2024
kajitack
1
520
Cloudflare MCP ServerでClaude Desktop からWeb APIを構築
kutakutat
1
540
From Translations to Multi Dimension Entities
alexanderschranz
2
130
これが俺の”自分戦略” プロセスを楽しんでいこう! - Developers CAREER Boost 2024
niftycorp
PRO
0
190
StarlingMonkeyを触ってみた話 - 2024冬
syumai
3
270
MCP with Cloudflare Workers
yusukebe
2
220
CSC305 Lecture 25
javiergs
PRO
0
130
テストコードのガイドライン 〜作成から運用まで〜
riku929hr
1
170
Featured
See All Featured
Statistics for Hackers
jakevdp
796
220k
Speed Design
sergeychernyshev
25
670
The Art of Programming - Codeland 2020
erikaheidi
53
13k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
280
13k
Thoughts on Productivity
jonyablonski
67
4.4k
We Have a Design System, Now What?
morganepeng
51
7.3k
Building a Modern Day E-commerce SEO Strategy
aleyda
38
7k
Building Your Own Lightsaber
phodgson
103
6.1k
Stop Working from a Prison Cell
hatefulcrawdad
267
20k
Unsuck your backbone
ammeep
669
57k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
28
9.1k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
330
21k
Transcript
(BNFQMBZ,JUͷհ !LJDIJLVDIJ TIJCVZBTXJGU
ࣗݾհ w ٠ل ,B[VOPSJ,JLVDIJ w !LJDIJLVDIJ w J04ΤϯδχΞ w
(.0ϖύϘɿNJOOFνʔϜ w 0CKFDUJWF$ྺɿͱ
(BNFQMBZ,JUͷલʹ w 4QSJUF,JU w J04Ҏ্ʹରԠ͢ΔήʔϜ։ൃ༻ϑϨʔϜϫʔΫ w εϓϥΠτʹΞχϝʔγϣϯΛઃఆ w ཧγϛϡϨʔγϣϯʹΑΔিಥͷ࠶ݱ w
ήʔϜͷΞχϝʔγϣϯ෦Λ୲
(BNFQMBZ,JUͱ w J04͔ΒՃ͞ΕͨήʔϜͷγεςϜ෦ͷجຊ ػೳΛఏڙͯ͘͠ΕΔϑϨʔϜϫʔΫ w ήʔϜͷγεςϜ෦Λ୲
(BNFQMBZ,JUͷΫϥε w ͍͔ͭ͘ϐοΫΞοϓ ৄ͘͠SFGΛࢀর w (,3BOEPN4PVSDF w (,3BOEPN%JTUSJCVUJPO w (,.JONBY4USBUFHJTU
w (,(SBQI w (,"HFOU w (,3VMF4ZTUFN
(BNFQMBZ,JUͷΫϥε w ͍͔ͭ͘ϐοΫΞοϓ ৄ͘͠SFGΛࢀর w (,3BOEPN4PVSDF w (,3BOEPN%JTUSJCVUJPO w (,.JONBY4USBUFHJTU
w (,(SBQI w (,"HFOU w (,3VMF4ZTUFN
(,3BOEPN4PVSDF w ཚΛੜ͢Δ let rundomNumber = GKRandomSource.sharedRandom().nextInt() let rundomNumber2
= GKRandomSource.sharedRandom().nextIntWithUpperBound(6) < d > <d> w ཚੜͷΞϧΰϦζϜ w "3$
༷ʑͳੜํ๏ w (,"3$3BOEPN4PVSDF w ໌ࣔతʹTFFEΛ༩͑ͯཚΛੜ͢Δ let rundomNumber = GKARC4RandomSource.init(seed:
data).nextInt() w ผΞϧΰϦζϜͰཚΛੜ w (,-JOFBS$POHSVFOUJBM3BOEPN4PVSDF w )JHI1FSGPSNBODF -PX3BOEPNOFTT w (,.FSTFOOF5XJTUFS3BOEPN4PVSDF w )JHI3BOEPNOFTT -PX1FSGPSNBODF
ྻͷγϟοϑϧ let numbers = [Int](1...100) let shuffledNumbers = GKRandomSource.sharedRandom().arrayByShufflingObjectsInArray(number
s)
(,3BOEPN%JTUSJCVUJPO w ಛఆͷ֬ʹجͮ͘ཚΛੜͰ͖Δ w (,(BVTTJBO%JTUSJCVUJPO w (,4IV⒐FE%JTUSJCVUJPO let diceNumber
= GKRandomDistribution.d6().nextInt() let asakusaLine = GKRandomDistribution.d20().nextInt() let original = GKRandomDistribution(randomSource: GKMersenneTwisterRandomSource(), lowestValue: 10, highestValue: 20).nextInt() <d> <d> <d>
(,(BVTTJBO%JTUSJCVUJPO w ਖ਼نʹجͮ͘ཚΛੜ for (var i = 0; i
< 10000; i++) { print(GKGaussianDistribution.d20().nextInt()) }
(,4IV⒐FE%JTUSJCVUJPO w ࢦఆ͞ΕͨൣғͷࣈΛ̍ճͮͭબ͢Δ for (var i = 0; i
< 10000; i++) { print(GKShuffledDistribution.d20().nextInt()) }
ཚͷҰ୴ऴΘΓʂ
͕͜͜Πέͯͳ͍Αʂ w 0CKFDUJWF$ͷΈͰར༻Մೳͳϝιου͕ଟ
͕͜͜Πέͯͳ͍Αʂʂ w 0CKFDUJWF$ w ϝιουɿݸ w 4XJGU w ϝιουɿݸ
·ͱΊ w (BNFQMBZ,JU֓ཁ w ήʔϜγεςϜ෦ͷ࡞ʹศརͳػೳΛଟఏ ڙͯ͘͠ΕΔ w (,3BOEPN΄ʹΌΒΒ w ༷ʑͳཚΛखܰʹੜ
w ήʔϜҎ֎Ͱར༻Մೳʂ w 0CKFDUJWF$ͷΈར༻Մೳͳϝιου͕ଟ