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

Games for Science by Jessica Hamrick

D21717ea76044d31115c573d368e6ff4?s=47 PyCon 2014
April 12, 2014
410

Games for Science by Jessica Hamrick

D21717ea76044d31115c573d368e6ff4?s=128

PyCon 2014

April 12, 2014
Tweet

Transcript

  1. Games for Science! Interactive psychology experiments in Python with Panda3D

    Jessica Hamrick (@jhamrick) jhamrick@berkeley.edu Peter Battaglia pbatt@mit.edu http://www.jesshamrick.com/ http://web.mit.edu/~pbatt/www/ Follow along: jhamrick.github.io/pycon-2014-talk
  2. The rise of games -- , May 2012 (emphasis added)

    Angry Birds games had so far been played a total of 200,000 years, with 300 million minutes of playing time daily. TNW Blog 300 million minutes = 5 million hours = 208,000 days = 570 years ... per day! What if we could leverage the popularity of games to do science?
  3. Fun games for interesting science! 1. The question 2. The

    hypothesis 3. The experiments
  4. How do people reason about the world?

  5. How do people reason about the world?

  6. How do people reason about the world?

  7. How do people reason about the world?

  8. How do people reason about the world?

  9. How do people reason about the world?

  10. Outline 1. The question: How do people reason about the

    physical world? 2. The hypothesis 3. The experiments
  11. Brain as a computer Computational cognitive science software (i.e., mind)

    Computational neuroscience hardware (i.e., brain)
  12. Computer models of behavior

  13. Physics games

  14. “The physics engine in your head” Approximate simulations are not

    exact Probabilistic simulations have some randomness
  15. Why approximate and probabilistic?

  16. Why a physics engine? Effective Simulations are sufficiently realistic Efficient

    Created to run in realtime General-purpose Applies to many situations
  17. Outline 1. The question: How do people reason about the

    physical world? 2. The hypothesis: "The physics engine in your head" 3. The experiments
  18. Ok, so how do we test this? We use video

    game tools as our theories, and in our experiments. Create a computational model using video game physics (e.g., ) Generate stimuli using a 3D modeling program (e.g., ) Run experiments using a video game framework (e.g., ) (All open source, and all with Python bindings!) Perform data analysis using other Python tools: NumPy, SciPy, pandas, IPython, matplotlib, etc. Bullet Blender Panda3D
  19. More information about the research I am just going to

    focus on the experiments, but if you're interested in the research, check out these links: Project page: PNAS journal article: Scientific American article: Fast Company article: http://web.mit.edu/~pbatt/www/PNAS2013/user.html http://www.pnas.org/content/110/45/18327.abstract http://www.scientificamerican.com/article/the-video-game-engine-in-your- head http://www.fastcodesign.com/3022236/evidence/how-our-brains-play- angry-birds-with-the-world
  20. Demo: “Which direction?”

  21. Demo: “Which direction?” 1:00 https://github.com/jhamrick/pycon-2014-talk/blob/master/demos/which_direction.py

  22. How does it work? 1. Create graphics models to depict

    the objects 2. Display the models with a rendering engine 3. Add physical dynamics with a physics engine 4. Link graphics and physics together We'll go through a conceptual overview of these steps. If you want to learn how to actually code it, you can find the code here: Panda3D also has a great "Hello, world!" tutorial here: https://github.com/jhamrick/pycon-2014-talk/blob/master/demos/tutorial.py https://www.panda3d.org/manual/index.php/A_Panda3D_Hello_World_Tutorial
  23. Step 1: Create a graphics model 3D objects are typically

    created in a modeling program like (which is Python scriptable!) Blender
  24. Step 2: Set up graphics Panda3D is a C++ game

    library with Python bindings
  25. Step 2a: Set up the scene graph

  26. Step 2b: Load the model

  27. Step 2c: Add it to the scene graph

  28. Step 2: The result

  29. Step 3: Set up physics is a mature C++ physics

    engine. Panda3d includes bindings to it, and it can be controlled through Python. To simulate physics, you need a B u l l e t W o r l d Keeps track of all the physics objects Computes new positions Handles collisions Physics objects consist of a shape (collisions) and a body (dynamics) Bullet
  30. Step 3a: Create the physics world

  31. Step 3b: Create collision geometry

  32. Step 3c: Create a physical body

  33. Step 3d: Add it to the physical world

  34. Step 3: The result 0:05

  35. Step 4: Link graphics and physics

  36. Step 4a: Add the body to the scene graph

  37. Step 4b: Link physics and graphics

  38. Step 4: The result 0:07

  39. Demo: “Glue blocks together to make the tower stable”

  40. Demo: “Glue blocks together to make the tower stable” 0:23

  41. Demo: “Bump the table”

  42. Demo: “Angry blocks 3D”

  43. Demo: “Angry blocks 3D” 0:31

  44. Conclusion Question: How do people reason about the physical world?

    Hypothesis: "The physics engine in your head" Tools: Blender, Panda3D, and Bullet
  45. Looking forward... -- , May 2012 (emphasis added) Angry Birds

    games had so far been played a total of 200,000 years, with 300 million minutes of playing time daily. TNW Blog Think how much we could learn if people participated in psychology experiments at that scale! With engaging and interactive physics experiments, it doesn't seem impossible.
  46. Thanks! People Josh Tenenbaum Tom Griffiths Computational Cognitive Science Lab

    @ MIT Computational Cognitive Science Lab @ Berkeley Tools Python Panda3D, Blender, and Bullet IPython, NumPy, and the rest of the SciPy stack Slides created with IPython notebook and reveal.js
  47. Links Slides and demo code: Project page: SceneSim library: PNAS:

    Scientific American: Fast Company: https://github.com/jhamrick/pycon-2014-talk http://web.mit.edu/~pbatt/www/PNAS2013/user.html http://scenesim.org/ http://www.pnas.org/content/110/45/18327.abstract http://www.scientificamerican.com/article/the-video-game-engine-in-your- head http://www.fastcodesign.com/3022236/evidence/how-our-brains-play- angry-birds-with-the-world
  48. IPython Notebook

  49. None
  50. None
  51. None
  52. None
  53. None
  54. None
  55. None
  56. None
  57. None
  58. None
  59. None
  60. None
  61. None
  62. None
  63. None
  64. None
  65. None
  66. None
  67. None
  68. None
  69. None
  70. None
  71. None
  72. None
  73. None
  74. None
  75. None
  76. None
  77. None
  78. None
  79. None
  80. None
  81. None
  82. None
  83. None
  84. None
  85. None
  86. None
  87. None
  88. None
  89. None
  90. None
  91. None
  92. None
  93. None
  94. None
  95. None
  96. None