Procedural Generation in Ruby

Da0b02303090f0ded442767e58a98626?s=47 Alex Taylor
December 01, 2016

Procedural Generation in Ruby

A lightning talk I did at VanRuby in December 2016. I talked about video games and pseudo-random number generators!

Da0b02303090f0ded442767e58a98626?s=128

Alex Taylor

December 01, 2016
Tweet

Transcript

  1. Procedural Generation in Ruby

  2. Alex Taylor @mctaylorpants

  3. Alex Taylor @mctaylorpants

  4. Alex Taylor @mctaylorpants 566034820233894 = Images from noelberry.ca

  5. Alex Taylor @mctaylorpants rand

  6. Alex Taylor @mctaylorpants def generate_world(seed = 123) end

  7. Alex Taylor @mctaylorpants

  8. Alex Taylor @mctaylorpants

  9. Alex Taylor @mctaylorpants rand != ‘truly random’

  10. Alex Taylor @mctaylorpants PRNG • Pseudo-random number generator • Appears

    random... • ...but actually deterministic rspec --seed 123
  11. Alex Taylor @mctaylorpants srand • Initializes Ruby’s PRNG • Per-process

  12. Alex Taylor @mctaylorpants a = [1, 2, 3, 4, 5]

    srand(123) a.sample => 3 a.sample => 5 a.sample => 3 a.shuffle => [1, 5, 3, 4, 2] rand => 0.7800277619120791
  13. Alex Taylor @mctaylorpants

  14. Alex Taylor @mctaylorpants a = [1, 2, 3, 4, 5]

    srand(123) a.sample => 3 a.sample => 5 a.sample => 3 a.shuffle => [1, 5, 3, 4, 2] rand => 0.7800277619120791
  15. Alex Taylor @mctaylorpants 123

  16. Alex Taylor @mctaylorpants LOVE ME

  17. Alex Taylor @mctaylorpants srand(123) a = ['n', 't', 'k', 'h',

    'a', 's'] a.shuffle.join => “thanks”