Upgrade to Pro — share decks privately, control downloads, hide ads and more …

GameplayKit, GKRandomSource, GKRandomDistribution

kichikuchi
October 23, 2015

GameplayKit, GKRandomSource, GKRandomDistribution

shibuya.swift #1 発表資料

kichikuchi

October 23, 2015
Tweet

More Decks by kichikuchi

Other Decks in Programming

Transcript

  1. ࣗݾ঺հ w ٠஑࿨ل ,B[VOPSJ,JLVDIJ  w !LJDIJLVDIJ w J04ΤϯδχΞ w

    (.0ϖύϘɿNJOOFνʔϜ w 0CKFDUJWF$ྺɿ೥ͱ൒೥ 
  2. (,3BOEPN4PVSDF w ཚ਺Λੜ੒͢Δ  let rundomNumber = GKRandomSource.sharedRandom().nextInt() let rundomNumber2

    = GKRandomSource.sharedRandom().nextIntWithUpperBound(6) <   d   > <d> w ཚ਺ੜ੒ͷΞϧΰϦζϜ w "3$
  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
  4. (,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>
  5. (,(BVTTJBO%JTUSJCVUJPO w ਖ਼ن෼෍ʹجͮ͘ཚ਺Λੜ੒  for (var i = 0; i

    < 10000; i++) { print(GKGaussianDistribution.d20().nextInt()) }     
  6. (,4IV⒐FE%JTUSJCVUJPO w ࢦఆ͞Εͨൣғͷ਺ࣈΛ̍ճͮͭબ୒͢Δ  for (var i = 0; i

    < 10000; i++) { print(GKShuffledDistribution.d20().nextInt()) }