Baruco 2014: How I Built My Own Twitch-Plays-Pokémon

Baruco 2014: How I Built My Own Twitch-Plays-Pokémon

As the slides don't really say much, the content of the talk is going to be published as a series of blogposts.
http://ajipirijou.com/talks/how-i-built-my-own-tpp-part-1

This talk was given at Baruco 2014.
It explains the story of How I built my own TPP.

570a76d7545a0ae4b693ffee5435717e?s=128

José Tomás Albornoz

September 12, 2014
Tweet

Transcript

  1. 1.

    When was the last time you worked on a non

    productive project, just for the fun of it?
  2. 4.
  3. 5.
  4. 6.
  5. 7.

    OMG

  6. 12.
  7. 13.
  8. 14.
  9. 21.
  10. 22.
  11. 23.
  12. 24.
  13. 25.

    Problems with the Windows solution • WINDOWS!!!!!111! • I have

    no Windows machine • I want to run this on a server with no desktop environment
  14. 26.
  15. 27.
  16. 28.

    require 'sinatra' mappings = { "a" => java.awt.event::KeyEvent::VK_Z, "b" =>

    java.awt.event::KeyEvent::VK_X, "up" => java.awt.event::KeyEvent::VK_UP, "down" => java.awt.event::KeyEvent::VK_DOWN, } robot = java.awt.Robot.new get '/:key' do |key| if key_code = mappings[key.downcase] robot.keyPress(key_code) robot.delay(100) robot.keyRelease(key_code) end end
  17. 29.
  18. 30.
  19. 31.
  20. 33.

    The perfect emulator • requires no desktop environment • streams

    the video online • has an API that allows to send button presses
  21. 34.
  22. 35.
  23. 36.
  24. 38.
  25. 39.
  26. 40.
  27. 42.
  28. 43.
  29. 45.
  30. 46.
  31. 48.
  32. 49.
  33. 51.

    address operation 0x00 nop 0x04 inc_b 0x80 add_a_b 0xA0 and_b

    0xC0 jp_nn CPU Instruction Table class CPU OPS = [ :nop, … … :inc_b, … :add_a_b, … :and_b, … :jp_nn, ]
  34. 52.

    “the” loop class Emulator def step next_byte = @ram[@program_counter] next_instruction

    = OPS[next_byte] @cpu.send(next_instruction) @program_counter += 1 end end
  35. 53.

    “the” loop class Emulator def step next_byte = @ram[@program_counter] #

    => 0xC0 next_instruction = OPS[next_byte] @cpu.send(next_instruction) @program_counter += 1 end end
  36. 54.

    “the” loop class Emulator def step next_byte = @ram[@program_counter] #

    => 0xC0 next_instruction = OPS[next_byte] # => :jp_nn @cpu.send(next_instruction) @program_counter += 1 end end
  37. 55.

    “the” loop class Emulator def step next_byte = @ram[@program_counter] #

    => 0xC0 next_instruction = OPS[next_byte] # => :jp_nn @cpu.send(next_instruction) @program_counter += 1 end end
  38. 56.

    “the” loop class Emulator def step next_byte = @ram[@program_counter] #

    => 0xC0 next_instruction = OPS[next_byte] # => :jp_nn @cpu.send(next_instruction) @program_counter += 1 end end
  39. 57.

    “the” loop class Emulator def step next_byte = @ram[@program_counter] #

    => 0xC0 next_instruction = OPS[next_byte] # => :jp_nn @cpu.send(next_instruction) @program_counter += 1 end end
  40. 62.

    Advantages • No need for keypresses • We can run

    on a headless server • We can stream closer to real-time
  41. 63.

    Advantages • No need for keypresses • We can run

    on a headless server • We can stream closer to real-time • We control the memory!
  42. 66.

    Advantages • version controlling of gameplays • rewind game sessions

    • forking and branching • machine learning
  43. 68.

    Advantages • No need for keypresses • We can run

    on a headless server • We can stream closer to real-time • We control the memory!
  44. 69.
  45. 70.
  46. 71.
  47. 72.
  48. 73.

    if you want to succeed at conferences you should totally

    promise stuff you have no idea about that’s p good
  49. 78.
  50. 83.
  51. 84.
  52. 85.
  53. 93.
  54. 94.

    “Ruby code that you wouldn't deploy at your day job

    because it's just too interesting or creative” - Steve Klabnik
  55. 96.

    “If you worry too much about being clean and tidy,

    you can’t push the boundaries” - _why
  56. 98.

    CPU Steps Step Operation A B C D E F

    1 nop 0 15 232 22 19 10 2 dec_d 0 15 232 21 19 10 3 inc_b 0 16 232 21 19 10
  57. 100.
  58. 101.
  59. 103.
  60. 104.
  61. 105.
  62. 106.
  63. 107.
  64. 108.
  65. 109.
  66. 111.
  67. 112.
  68. 113.
  69. 114.
  70. 115.
  71. 116.
  72. 117.
  73. 118.
  74. 120.
  75. 122.
  76. 123.
  77. 124.
  78. 125.
  79. 126.
  80. 127.
  81. 128.
  82. 129.
  83. 130.
  84. 131.
  85. 139.