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.7k
tableViewとcoolectionviewのパフォーマンスチューニング
kichikuchi
1
550
AB Tests in Mobile App
kichikuchi
1
1.9k
Other Decks in Programming
See All in Programming
Content Security Policy入門 セキュリティ設定と 違反レポートのはじめ方 / Introduction to Content Security Policy Getting Started with Security Configuration and Violation Reporting
uskey512
1
490
詳細解説! ArrayListの仕組みと実装
yujisoftware
0
560
プロジェクト新規参入者のリードタイム短縮の観点から見る、品質の高いコードとアーキテクチャを保つメリット
d_endo
1
1.1k
イベント駆動で成長して委員会
happymana
1
300
Quine, Polyglot, 良いコード
qnighy
4
630
初めてDefinitelyTypedにPRを出した話
syumai
0
240
Hotwire or React? ~アフタートーク・本編に含めなかった話~ / Hotwire or React? after talk
harunatsujita
1
110
CPython 인터프리터 구조 파헤치기 - PyCon Korea 24
kennethanceyer
0
250
Click-free releases & the making of a CLI app
oheyadam
2
110
WebフロントエンドにおけるGraphQL(あるいはバックエンドのAPI)との向き合い方 / #241106_plk_frontend
izumin5210
4
1.3k
推し活の ハイトラフィックに立ち向かう Railsとアーキテクチャ - Kaigi on Rails 2024
falcon8823
6
2.8k
Macとオーディオ再生 2024/11/02
yusukeito
0
350
Featured
See All Featured
Designing for humans not robots
tammielis
250
25k
Bash Introduction
62gerente
608
210k
Being A Developer After 40
akosma
86
590k
Code Reviewing Like a Champion
maltzj
520
39k
How to Think Like a Performance Engineer
csswizardry
20
1.1k
Unsuck your backbone
ammeep
668
57k
[RailsConf 2023] Rails as a piece of cake
palkan
51
4.9k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
665
120k
The Cost Of JavaScript in 2023
addyosmani
45
6.7k
Designing the Hi-DPI Web
ddemaree
280
34k
Optimising Largest Contentful Paint
csswizardry
33
2.9k
Bootstrapping a Software Product
garrettdimon
PRO
305
110k
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$ͷΈར༻Մೳͳϝιου͕ଟ