Approximate Space Physics for Online Game

In summary: That's actually why I was thinking about approximating it with classical physics. But I'm not even sure if that's the right thing to do.In summary, the indie game developer is looking for suggestions on how to approximate effects in his game that would be difficult for computers to do correctly. He is unsure of where to even start.
  • #1
dylankarr.com
13
0
Hi,

I'm an indie game developer working on a free online puzzle/simulation game set in space. The object of the game is to move, resize, push, pull and otherwise manipulate celestial bodies to solve problems, like putting a planet in a stable orbit or accelerating a satellite to near lightspeed. I want the game to be at least slightly educational and therefore somewhat scientifically accurate. The only problem is that this game is designed to work in web browsers, so there are quite a few processing restraints on how accurate the game's calculations can be, and I need some help creating more approximate, faster equations for modeling planetary and stellar physics.

Currently, I have bodies moving in a classical manner, obeying Newton's law of gravitation by applying a force proportional to its mass and inversely proportional to the square of it's distance to every object within a radius where it's gravitational influence will be significant. I've also given the player the ability to speed and slow time at will and to adjust the mass of objects as well (at a cost of a certain number of points). Players can also 'grab' bodies and move them about in realtime or while paused to affect their trajectories and influence bodies around them.

What I'd like to add is things like Tidal Lock, Frame Dragging, Geodetic effects, and Special Relativity (currently their is no lightspeed limit). The problem is that all of these things require me to account for things like the curvature of spacetime or time-like dimensions, which if you've ever worked with computers in modeling these sorts of things before, you'll probably know them to be a very hard thing for computers to do. I was thinking that because I don't necessarily need my game to be perfectly accurate for my purposes, I might be able to create some sort of classical approximations to these effects to use instead. However, I don't even really know where to start in creating an equation like that, and when I googled it, as far as I could tell, no one else has ever tried. So, basically, I was just wondering if anyone here had any ideas or if someone could even give me a place to start?
 
Physics news on Phys.org
  • #2
After reading over my original post, I thought I might need to be a bit more specific. One equation I think I need to work out is how much torque is imposed on a body by another body rotating about it. The mass of the first body could be represented by ma and the mass of the second by mb. The angular velocity of the bodies would be represented by [tex]\varpi_{a}[/tex] and [tex]\varpi_{b}[/tex]. The velocity of the second body relative to the first one can be represented by v. The distance between the bodies can be represented by d. So the equation would be something like:

[tex]\tau = Am^{\alpha}_{a} + Bm^{\beta}_{b} + G\varpi^{\gamma}_{a} + E\varpi^{\epsilon}_{b} + D\varpi^{\delta}_{\bot} / d^{2}[/tex]

Only, I don't know what the constants are, and I don't know enough about frame dragging to figure them out. Can anyone help me out?
 
Last edited:
  • #3
I don't see any reason why the calculations need to be that complicated honestly. Some of the things you want to add have effects that are so small or that take so long, you would seriously need to jack up their values for it to be noticeable in a game. And the equations for limiting the speed of an object to stay under light speed isn't that complicated.

You should be able to hit up wikipedia and find the equations and constants (or the links to them) on the page about whichever topic you are looking up. For example, just looking up Frame Dragging I see that it has several equations and links with them to various other equations and constants. Same thing for Torque. It might take a bit of work, but shouldn't be too terribly difficult.
 
  • #4
Drakkith said:
I don't see any reason why the calculations need to be that complicated honestly. Some of the things you want to add have effects that are so small or that take so long, you would seriously need to jack up their values for it to be noticeable in a game. And the equations for limiting the speed of an object to stay under light speed isn't that complicated.

Well, the reason for having these effects at all comes in that the user can speed up time, so over an extremely long period of time, say a year, these frame dragging may result in noticeable changes, and if I'm not mistake (which I may be), tidal lock is caused by gravitomagnetic effects, right? So these factors would be very important in simulating that.

As for special relativity, I'm having a bit of trouble implementing in computable terms. I understand the theory very well, but when you actually put it into practice (sort of) in a computer things go wonky. For example, as I have it, the primary limiting factor for preventing bodies from exceeding the speed of light is that their mass increases as they approach it, thus the forces applied to them by other bodies become less effective due to F=ma, but this has two downsides:
  1. As it approaches light speed, gravity has less of an affect on the body, because gravity in this system is Newtonian and applied just like other forces, which in the real world it is not. Real gravity curves spacetime itself and can therefore move things as fast as it wants to, because it's not really the bodies moving, but rather the space on which they rest.
  2. As bodies go faster and faster and their mass gets bigger and bigger, they approach infinity, and computers don't like infinity. Of course, they never really get there, but as they get close, other things in my game engine, like collision checking, path rendering, and lighting, start to break down.

Drakkith said:
You should be able to hit up wikipedia and find the equations and constants (or the links to them) on the page about whichever topic you are looking up. For example, just looking up Frame Dragging I see that it has several equations and links with them to various other equations and constants. Same thing for Torque. It might take a bit of work, but shouldn't be too terribly difficult.

I did look these things up, and everything I found was either far more complex than I could understand or was expressed in a form I couldn't model in my simple browser-based implementation, like a metric. Metrics are brilliant in theoretical physics, but when it comes to modeling things they're horrible, because they force you to calculate values for every inch of space. I was hoping someone here could help dumb it down for me, but if not, I may just make something up, like:

[tex]\tau_{a} = 0.0001* \omega_{b}\upsilon_{\bot}/d^{2}[/tex]
 
  • #5
Would it help if you don't have an increase in mass and instead just have a diminishing effect for increasing speed? I don't see a need to increase an objects mass at all. From that objects frame it never has any increase in mass.
EDIT: Also, an objects gravitational mass doesn't increase anyways, so there is no need for that to happen in the game.

Metrics are brilliant in theoretical physics, but when it comes to modeling things they're horrible, because they force you to calculate values for every inch of space.

Have you played Universe Sandbox? They implement something where everything is calculated in time steps that you can increase or decrease. Speeding up the game too far results in weird things happening because the time steps become so large.
 
  • #6
Unless you're very careful about your integration algorithm, your simulator won't actually conserve momentum and energy. A symplectic integrator will help considerably. Wiki seems to have a pretty good introduction to this. http://en.wikipedia.org/w/index.php?title=Symplectic_integrator&oldid=426856468. You'd want to cast your equations of motion into Hamilton's form to use a symplectic integrator.

Without a symplectic integrator, you'll find your planets spiraling in or out from the central body due to small simulator errors per step acccumulating over many steps.

As far as torques go, what you need to do is a multi-pole expansion of your bodies potential.

http://www.mathematics.thetangentbundle.net/wiki/Potential_theory/spherical_multipole_expansion

has some info, it's a bit hard to read. You might consider picking up Goldstein's "Classical Mechanics", that discusses the issue and works out a few related problems.

You wouldn't really need to keep many terms in the multiple expansion for what you want, I think.

Finally, you can use the PPN equations to include the low order relativistic effects. I'm not sure if this is worthwhile, especially if you also want to keep the integrator symplectic. PPN stands for "parameterized post Newtonian", it's a formalism that works well when things are almost Newtonian, but "not quite".

It looks like http://arxiv.org/PS_cache/gr-qc/pdf/9906/9906123v1.pdf does a lot of the work for finding the PPN equations for N massive bodies with specified multiple moments for you, which would be a daunting task. But I'd be surprised if you can get this level of detail to run on a webpage / game.
 
Last edited by a moderator:
  • #7
Drakkith said:
Would it help if you don't have an increase in mass and instead just have a diminishing effect for increasing speed? I don't see a need to increase an objects mass at all. From that objects frame it never has any increase in mass.
EDIT: Also, an objects gravitational mass doesn't increase anyways, so there is no need for that to happen in the game.

How would you implement this diminishing effect? Would it just be that when ever a force is applied to the body it's reduced by the lorentz factor for that body? Or would it be that I keep the 'real' (relative to the player) velocity of the object stored separately and use it to calculate the bodies 'effective' velocity? Even with this, a lot of stuff is still up in the air, like the simultaneity of events. How am I supposed to know when two stars collide if the player is in one reference frame and the stars are in another? I could model it with multiple reference frames, but that would prevent me from modeling the game in realtime as the player interacted with bodies.

Drakkith said:
Have you played Universe Sandbox? They implement something where everything is calculated in time steps that you can increase or decrease. Speeding up the game too far results in weird things happening because the time steps become so large.

I've played it now that you've pointed it out. I can see how it works, and it's a bit too high power for my simple browser based game, but it looks like a lot of fun. I don't like that it's only for windows, though. I dual boot, so I can play it, but I'm really more of a mac guy.
 
  • #8
In my experience, properly-implemented special relativity actually results in more stable behavior over time, as compared to Newtonian mechanics. The reason is that the universal speed limit prevents objects from moving too much in one time step.

I've written my own simulator before...a screensaver where a bunch of balls bounce around on screen, according to the rules of special relativity. The speed of light is adjustable. Every time there is a collision, you must Lorentz transform to the center of momentum for that collision, compute the new velocities, and then Lorentz transform back to the lab frame.

Including forces in special relativity is trickier. You must forget about the idea of "relativistic mass", because it does not work that way (you cannot simply take Newton's laws and replace mass with relativistic mass). All physics in special relativity must be given Lorentz-covariant formulations. For example, electromagnetism acts via

[tex]\ddot x^\mu = \frac{e}{m} F^\mu{}_\nu \dot x^\nu[/tex]

where [itex]\dot x^\mu[/itex] is the 4-velocity, [itex]F^\mu{}_\nu[/itex] is the Maxwell two-form with first index raised, e is the electric charge, and m is the invariant mass. Dots represent derivatives with respect to proper time, not lab time, so you will have to be careful about gamma factors.

Speaking of integrators, Verlet and Velocity Verlet are very simple symplectic integrators. Verlet is sufficient if objects are moving in straight lines (as in my relativistic billiard balls program). Velocity Verlet is quite good if objects are affected by forces...the errors caused by Velocity Verlet tend to oscillate over time rather than trending in one direction or the other.
 
Last edited:
  • #9
dylankarr.com said:
How would you implement this diminishing effect? Would it just be that when ever a force is applied to the body it's reduced by the lorentz factor for that body? Or would it be that I keep the 'real' (relative to the player) velocity of the object stored separately and use it to calculate the bodies 'effective' velocity? Even with this, a lot of stuff is still up in the air, like the simultaneity of events. How am I supposed to know when two stars collide if the player is in one reference frame and the stars are in another? I could model it with multiple reference frames, but that would prevent me from modeling the game in realtime as the player interacted with bodies.

I think Ben and Pervect answered most of this pretty well, but I just wanted to add a thing or two.

In regards to the frame and knowing when things happen, simply keeping everything in the frame of the player would accomplish that. If object X is at 15% c, and object Y is at 25% c, and they collide, both of those speed values are in relation to the observer. Remember that it is entirely possible to follow something around with a camera without "entering" its frame of reference. ALSO, I would most definitely take any delay in observation time out of it and keep everything "instantly observable" by the player unless you REALLY want to implement that. I think it would just add confusion as to why something isn't happening when the player changes something.
 
  • #10
dylankarr.com said:
Hi,

I'm an indie game developer working on a free online puzzle/simulation game set in space. The object of the game is to move, resize, push, pull and otherwise manipulate celestial bodies to solve problems, like putting a planet in a stable orbit or accelerating a satellite to near lightspeed. I want the game to be at least slightly educational and therefore somewhat scientifically accurate. The only problem is that this game is designed to work in web browsers, so there are quite a few processing restraints on how accurate the game's calculations can be, and I need some help creating more approximate, faster equations for modeling planetary and stellar physics.

Currently, I have bodies moving in a classical manner, obeying Newton's law of gravitation by applying a force proportional to its mass and inversely proportional to the square of it's distance to every object within a radius where it's gravitational influence will be significant. I've also given the player the ability to speed and slow time at will and to adjust the mass of objects as well (at a cost of a certain number of points). Players can also 'grab' bodies and move them about in realtime or while paused to affect their trajectories and influence bodies around them.

What I'd like to add is things like Tidal Lock, Frame Dragging, Geodetic effects, and Special Relativity (currently their is no lightspeed limit). The problem is that all of these things require me to account for things like the curvature of spacetime or time-like dimensions, which if you've ever worked with computers in modeling these sorts of things before, you'll probably know them to be a very hard thing for computers to do. I was thinking that because I don't necessarily need my game to be perfectly accurate for my purposes, I might be able to create some sort of classical approximations to these effects to use instead. However, I don't even really know where to start in creating an equation like that, and when I googled it, as far as I could tell, no one else has ever tried. So, basically, I was just wondering if anyone here had any ideas or if someone could even give me a place to start?

One test of computer modeling of relativity is the orbit of Mercury. Using Newton's law of gravitation by applying a force proportional to its mass and inversely proportional to the square of it's distance can never model the orbit as every 2-body simulation will be an ellipse regardless of starting points, velocities or mass. One of the easiest ways to achieve the precession of Mercury's orbit (or precession for any 2-body system), is to introduce a fraction of m/r^3 and add it to the m/r^2 that you are already using. You instantly get very nice precession on 2-body orbits, lots of other neat effects and an ability to much more accurately model Mercury's orbit then Newtons laws allow.

I assume this works (although I never seen this derived, I have just seen the simulations work well) since the force could be approximated as a polynomial with higher terms http://en.wikipedia.org/wiki/Polynomial_interpolation" ie. at large distances m/r^2 donimates and at closer distances, m/r^3 becomes more important. This is very fast and easy for computer simulations to calculate for many body systems. When you get up to very fast speeds (ie over 50% of c), you will have to start worrying about your definition of masses, but at slower speeds, this adjustment appears to correct a lot of error in the simulations of planets.
 
Last edited by a moderator:
  • #11
Thanks everyone. I incorporated your ideas and physics seem to be working correctly. I'll post a link when the game is done.
 

1. What is approximate space physics for online game?

Approximate space physics for online game is a simplified version of real-life space physics that is used in online games. It aims to create a realistic and immersive gaming experience by simulating the effects of gravity, mass, and other physical forces on objects in space.

2. How is approximate space physics implemented in online games?

Approximate space physics is typically implemented using mathematical equations and algorithms that take into account the properties of objects in the game and their interactions with each other. These calculations are often simplified to ensure smooth gameplay and fast processing.

3. Does approximate space physics affect gameplay in online games?

Yes, approximate space physics can greatly affect gameplay in online games. It can make movements and interactions between objects more realistic and challenging, and can also add an extra layer of strategy to the game.

4. Are there any limitations to approximate space physics in online games?

There are some limitations to approximate space physics in online games, as it is not a perfect simulation of real-life physics. Some aspects, such as the speed of light and the effects of air resistance, may be simplified or ignored in order to maintain the game's performance and playability.

5. How does approximate space physics impact the overall gaming experience?

Approximate space physics can greatly enhance the overall gaming experience by adding a sense of realism and immersion to the game. It can also provide an additional level of challenge and complexity for players to master, making the game more engaging and enjoyable.

Similar threads

Replies
1
Views
46
  • Special and General Relativity
Replies
26
Views
2K
Replies
9
Views
952
  • Special and General Relativity
Replies
14
Views
1K
Replies
3
Views
1K
  • Special and General Relativity
Replies
13
Views
1K
  • Special and General Relativity
Replies
15
Views
2K
  • Computing and Technology
Replies
2
Views
1K
  • Science Fiction and Fantasy Media
Replies
4
Views
2K
Back
Top