Creating a Physics-Based Video Game: A Journey to Learn Relativity

In summary: The only thing you will need to get started is a computer and an internet connection. Everything else is included in the game.In summary, if you are interested in General Relativity, you should start by looking into Special and General Relativity articles. After that, you can try to solve the equations for yourself or use a software like Mathworks to solve them for you. If you are interested in developing the physics based game, you should first develop a basic simulation using Newton's laws. After that, you can implement improvements in the coding and math and worry about trying to model black holes accurately. Finally, you should look into
  • #1
gradev
9
2
Hi,

I'm trying to make a physics based game to teach my progeny about the universe. My first step will be to show how bodies gravitate around other bodies, and then model a solar system, a galaxy... simple things.
I could do it using Newton's laws, but I want to include things like black holes, and do it right, so I've been reading about Special and General Relativity, two-body problems, Riemannian and Lorentzian geometry... and seriously, I'm so lost I don't know where I am. But, even if it's only a game for children, I want to create the most accurate model possible for a real time application, like a framework for future upgrades.

Said that, I'm good with logic, and a very good software developer, but it's been a long time since I did something interesting using physics, and even my math is, well, not as good as it should.

So, I come here to ask you two questions:
1. Is it worth using General Relativity?
2. If it is: Where should I start to learn how to do this from scratch?

I know this is a very broad question, and you may think I'm just a dreamer... I don't expect it to be easy, but I've been a self learner for a very long time, so I just need a start point, a fulcrum if you want, to start moving in the right direction.

Thanks in advance.
 
Physics news on Phys.org
  • #2
Forget even attempting to use GR for anything. It is ENORMOUSLY complicated to try to use GR's equations to model anything and without years and years of study you won't be anywhere close to being able to do so. I don't think you can even solve the equations fast enough to run your model in real-time, let alone fast enough to create a useable game that runs on the average PC and is able to potentially model hundreds if not thousands of objects at a time.

Your first step should be to use Newton's laws to develop a basic simulation. Once you have this down, you can implement improvements in the coding and math and then worry about trying model black holes accurately.

Try looking through the following blog from the developers of Universe Sandbox. I don't know if it will be of any help, but it looks promising: http://universesandbox.com/blog/2016/02/n-body-problem/
 
  • Like
Likes gradev
  • #3
What is this game supposed to do?
 
  • Like
Likes gradev
  • #4
Thanks for your answers.

#2 My idea is not to process all the universe all the time. Using an influence radius for each body and computing only bodies influenced by those near the observer (the screen/camera) should optimize it enough for a RT simulation (at the cost of real accuracy, of course). If tests show that's not enough I could use CUDA to compute the model using the graphics card power, although I'd prefer not to do that right now.
If the result is going to be the same I could go back to Newton's. This doesn't seem to be the case for Mercury and other bodies, but I may be completely wrong about that, and I don't know how important is the difference and/or if it's relevant in my case scenario. That's why I ask if it's worth it.
Anyway, my little child is only a week old right now, so I have some years to re-learn math, physics and everything needed.
Sometimes I plan too far ahead for my own sake, I know, but while doing this I was hoping to learn other "useful" stuff. So, if it is worth it, I'm prepared to do it, step by step, no hurries. If it's not, I'll go back to Newton's. In any case I'll do it as accurate as possible.
Thanks for the universal sandbox link. The whole project looks very interesting.

#3 The base idea is a 2D celestial simulation (bodies orbiting and colliding with other bodies and/or exploding/breaking/joining). The next step would be to add sun birth-death cicles, and go on from there.
2D should simplify calculus, and helps understanding what you see in the screen, but I could do it in 3D if that makes the calculus easier (using a perfect Z axis alignment (like a traditional top-down view)).
[EDIT: I thought about using 2D because I saw (not sure where right now) that GR works with any amount of physical dimensions, and Newton's laws are easily applied to 2D scenarios, but I'm still not sure about accuracy in 2D].
The game part is:
1. In sandbox mode you will be able to create and move/throw bodies (a sun, a planet, a moon...). You could cause a mass destruction event just by adding a black hole or pushing a body (my 8yrs old nephew thinks that would be a very fun thing to do), or make your own universe from scratch.
2. In puzzle mode you will solve tests like "put this planet somewhere to make it orbit this binary system for at least 100yrs", "throw this 'rock', from point A to point B, passing near this 3 planets" or "build a solar system using these bodies (suns, planets, etc.)".
That would show how gravity works, how the solar system works, what is a supernova... and, if I can use a general object for every celestial body (a moon and a planet are 'mostly' the same thing in different circumstances, and share at least some properties with suns, black holes...) it could show how the universe works (at least at the most basic level).
In both modes I'll add 'play', 'pause', 'restart', 'create snapshot' and 'load snapshot' options to help setting things right and go over possible scenarios many times.

If you [EDIT: meaning, people who knows about this stuff] think it's better to use Newton's laws and then migrate to General Relativity, or not to use GR at all, I could do that by isolating the physics engine from the rest of the game (although for GR I'm guessing the render engine would need to be different).
Using Newton's laws would be easier, but right now my knowledge is too small to know if I should stick to that or not.
Also, maybe using Newton's will help me recover my math and physics skills, and that may even give me some insights about how to proceed if I end up learning about GR, so both options could be ok, but that could also give me wrong ideas (I've seen some questions and answers about mistakes made because some assumptions are not valid when using GR).

Again, thanks for your time and help. I really appreciate it.
 
Last edited:
  • Like
Likes Buffu
  • #5
@gradev, I wondered about GR simulation too and after reading about it in various places I concluded that it's far beyond what an amateur could take on. It seems this is an area of active research in astrophysics involving many PhDs, big expensive supercomputers and certainly much $$$. Just Google "computational general relativity" or "numerical general relativity".

To get an idea of the difficulty you can try something similar in nature but "much simpler", like simulating charged particle interactions. Keep in mind that such particles do not really interact with each other by inverse square law, they actually interact with the local EM field, which, by the way, will be a dynamic EM field not just an electrostatic field. The challenge of the simulation is to correctly evolve this EM field over time and space.

For your specific need, yes, stick to Newtonian gravity.
 
  • Like
Likes gradev
  • #6
Thanks @Vitro . Seems like you and @Drakkith are right, so I'm going to take the Newtonian approach, although I still don't know exactly how big is the Newton's "error", so I feel like I'm taking the easy path but not necessarily the right path.
Anyway, every engine part (gfx, physics, etc.) could be upgraded independently, so I'm not going to close the door to more complex options (sooner or later I'll go there).
Now I just need to get the sim right, so I'll be around re-learning everything.
Thanks all.
 
  • #7
For solar system simulations at the precision used by professional astronomers (including perihelion precessions), you only need first level of correction to Newtonian gravity. This won't help with any ambitious goals like black holes. The following describes this first order correction sheme:

https://en.wikipedia.org/wiki/Einstein–Infeld–Hoffmann_equations

This will still be challenging, but it is much more plausible than a general GR simulator (which has never been achieved).
 
  • Like
Likes gradev
  • #8
PAllen said:
it is much more plausible than a general GR simulator (which has never been achieved)
Wow, I did not imagine something like that. Being something so important I thought it was already simulated many times.
Thanks for the link @PAllen. I think I'm beginning to understand my own ignorance.
 
  • #9
Also remember Newtonian methods predict all planetary motion to a very high degree. The exception was the orbit of Mercury which was finally explained by GR.

However when you start factoring in black holes and neutron stars GR effects will be more noticeable.

Heres a game kit to bring in special relativity

http://gamelab.mit.edu/research/openrelativity/

There may also be libraries for GR but i have yet to find them.
 
  • Like
Likes gradev
  • #10
gradev said:
Wow, I did not imagine something like that. Being something so important I thought it was already simulated many times.
Thanks for the link @PAllen. I think I'm beginning to understand my own ignorance.
For nontrivial situations, especially for high precision, each case numerically solved is a research project leading to a paper suitable for publication in a peer reviewed journal.
 
  • Like
Likes gradev
  • #11
  • Like
Likes gradev
  • #12
gradev said:
Thanks @Vitro...I still don't know exactly how big is the Newton's "error"
Well, NASA planned all of it's manned space trips just using Newton. I'm not sure about the farther out unmanned missions.
 
  • Like
Likes gradev
  • #14
PAllen said:
However, this seems to be the closest thing to do it yourself tools for GR simulation:

https://einsteintoolkit.org/
The user guide states almost all work with these codes will require access to a supercomputer. The most common one used is the is the Queen Bee supercomputer, with over 5000 cores as of a few years ago.
 
  • #15
phinds said:
Well, NASA planned all of it's manned space trips just using Newton. I'm not sure about the farther out unmanned missions.

I'd certainly agree that General Relativity (henceforth GR) is probably not needed for a game for kids. But it's worth mentioning that the JPL Orbital Ephermerides, DE405, used for instance in "The Astronomical Almanac", does incorporate corrections due to GR - and quite a few other things.

see for instance 8.3 of ftp://ssd.jpl.nasa.gov/pub/eph/planets/ioms/ExplSupplChap8.pdf

I'd cut and paste the interesting section from the above link, but cutting and pasting yields horribly formatted results, and it's too long to type out manually.

As far as how to teach kids - I'm not sure how to go about it. Fighting math phobia, and minimizing social pressures against science, and finally teaching kids critical thinking, all strikes me as much needed goals. The last seems especially needed, nowadays, and I gather some efforts are underway to teach that at some level.
 
  • Like
Likes gradev
  • #16
pervect said:
I'd certainly agree that General Relativity (henceforth GR) is probably not needed for a game for kids. But it's worth mentioning that the JPL Orbital Ephermerides, DE405, used for instance in "The Astronomical Almanac", does incorporate corrections due to GR - and quite a few other things.

see for instance 8.3 of ftp://ssd.jpl.nasa.gov/pub/eph/planets/ioms/ExplSupplChap8.pdf

I'd cut and paste the interesting section from the above link, but cutting and pasting yields horribly formatted results, and it's too long to type out manually.

As far as how to teach kids - I'm not sure how to go about it. Fighting math phobia, and minimizing social pressures against science, and finally teaching kids critical thinking, all strikes me as much needed goals. The last seems especially needed, nowadays, and I gather some efforts are underway to teach that at some level.
And if you look at the main equation in that section, you find that it is exactly equivalent to the Einstein Infeld Hoffman equation I posted a link to earlier (except for a simplified special treatment for asteroids).

But also note that that what Phinds said is historically true.
 
  • Like
Likes gradev
  • #17
phinds said:
Well, NASA planned all of it's manned space trips just using Newton. I'm not sure about the farther out unmanned missions.

Good time to mention Kerbal Space Program : https://kerbalspaceprogram.com/en/
 
  • Like
Likes gradev
  • #18
phinds said:
Well, NASA planned all of it's manned space trips just using Newton. I'm not sure about the farther out unmanned missions.

I have even read/seen that the Apollo missions where flown with the same one body simplification (spheres of influence) used in Kerbal Space Program
 
  • Like
Likes gradev
  • #19
phinds said:
Well, NASA planned all of it's manned space trips just using Newton. I'm not sure about the farther out unmanned missions.
Well, that settles my doubts about Newton :)
jedishrfu said:
There's also a book by Kip Thorne on the simulations used in the Interstellar movie:
https://www.amazon.com/dp/0393351378/?tag=pfamazon01-20
I'll take a look. At the very least that could be an interesting reading.
pervect said:
As far as how to teach kids - I'm not sure how to go about it. Fighting math phobia, and minimizing social pressures against science, and finally teaching kids critical thinking, all strikes me as much needed goals. The last seems especially needed, nowadays, and I gather some efforts are underway to teach that at some level.
As far as I know, kids need something fun/interesting/weird to catch their attention. Forcing knowledge IMHO is a huge mistake, but if they find stimuli around (a piano, hand painting, a math game where numbers are like pets...) they'll try some things and learn by playing. Also, by studying their behavior parents/tutors can learn what they like, so they can increase the kid's stimuli in the "right" direction. And, since the kids are making choices, their minds will tend to analyze their options, improving their critital thinking.
Well, that's still theoretical for me, so do not take my word for it. I'm new to parenting.
sdkfz said:
Good time to mention Kerbal Space Program : https://kerbalspaceprogram.com/en/
Hmm, interesting game ^_^
 
  • #20
Also checkout processing.org and its IDE. It's geared toward non-programmers, beginning programmers and graphic artists who want to make interactive art. It comes with a lot of examples, modes and libraries.
 
  • Like
Likes gradev
  • #21
jedishrfu said:
Also checkout processing.org and its IDE. It's geared toward non-programmers, beginning programmers and graphic artists who want to make interactive art. It comes with a lot of examples, modes and libraries.
Thanks @jedishrfu . I'm already a fine programmer, but I'll take a look. You never know where you'll find an awesome idea ;)
 
  • #22
I was thinking more about your kids learning to program.
 
  • Like
Likes gradev
  • #23
jedishrfu said:
I was thinking more about your kids learning to program.
I can see it's potential, and the latest improvements are appealing, but for teaching programming to kids I think I prefer scratch. IMO The IDE looks friendlier, but things change quickly enough, so I'll keep an eye on processing.org. Thanks!
 
  • #24
Scratch for elementary school kids whereas processing is for higher grades.
 
  • Like
Likes gradev
  • #25
Hmm, sounds like a good idea @jedishrfu . Thanks again.
 
  • #26
PAllen said:
The user guide states almost all work with these codes will require access to a supercomputer. The most common one used is the is the Queen Bee supercomputer, with over 5000 cores as of a few years ago.
It is possible to do smaller simulations on a single machine, but nothing particularly impressive unless you like gnuplot graphs ;)
 
  • #27

1. How is relativity incorporated into the physics of the video game?

The principles of relativity are incorporated into the video game by using mathematical equations and programming algorithms to simulate the effects of time dilation, length contraction, and the speed of light in the game environment. This allows players to experience the effects of relativity in a virtual world.

2. Are there any real-life physics concepts that players can learn from playing the game?

Yes, players can learn about the basics of relativity and how it affects the movement of objects in space. They can also learn about the relationship between mass, energy, and the speed of light through gameplay mechanics and challenges.

3. What inspired you to create a physics-based video game about relativity?

As a scientist, I have always been fascinated by the concept of relativity and its impact on our understanding of the universe. I wanted to find a way to make this complex concept more accessible and engaging for people, and a video game seemed like the perfect medium to do so.

4. Is there any scientific research or data that went into the development of the game?

Yes, the development of the game involved extensive research on the principles of relativity, as well as consultations with experts in the field of physics. We also used real-life data and equations to accurately simulate the effects of relativity in the game.

5. Can players customize the physics settings in the game?

Yes, players have the option to adjust the physics settings in the game to their liking. They can choose to change the speed of light, the strength of gravity, and other variables to experiment with different scenarios and see how it affects the gameplay.

Similar threads

  • Special and General Relativity
Replies
12
Views
2K
  • Special and General Relativity
Replies
1
Views
1K
  • Special and General Relativity
Replies
12
Views
1K
Replies
4
Views
624
  • Special and General Relativity
Replies
11
Views
993
Replies
3
Views
912
Replies
7
Views
2K
  • STEM Educators and Teaching
Replies
4
Views
845
  • General Discussion
Replies
9
Views
1K
  • Special and General Relativity
2
Replies
43
Views
7K
Back
Top