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

Baruco 2014: How I Built My Own Twitch-Plays-Po...

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.

José Tomás Albornoz

September 12, 2014
Tweet

More Decks by José Tomás Albornoz

Other Decks in Technology

Transcript

  1. When was the last time you worked on a non

    productive project, just for the fun of it?
  2. OMG

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

    no Windows machine • I want to run this on a server with no desktop environment
  4. 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
  5. The perfect emulator • requires no desktop environment • streams

    the video online • has an API that allows to send button presses
  6. 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, ]
  7. “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
  8. “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
  9. “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
  10. “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
  11. “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
  12. “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
  13. Advantages • No need for keypresses • We can run

    on a headless server • We can stream closer to real-time
  14. Advantages • No need for keypresses • We can run

    on a headless server • We can stream closer to real-time • We control the memory!
  15. Advantages • version controlling of gameplays • rewind game sessions

    • forking and branching • machine learning
  16. Advantages • No need for keypresses • We can run

    on a headless server • We can stream closer to real-time • We control the memory!
  17. if you want to succeed at conferences you should totally

    promise stuff you have no idea about that’s p good
  18. “Ruby code that you wouldn't deploy at your day job

    because it's just too interesting or creative” - Steve Klabnik
  19. “If you worry too much about being clean and tidy,

    you can’t push the boundaries” - _why
  20. 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