Opinion on 'simulation' design
Opinion on 'simulation' design
I've posted before about the making of my game project. So far I've gotten all the physics and such pretty much completed and I'm on to creating the actual content.
I'm thinking of making it a mission-planning style game, where the player gets to design probes/satellites/etc, plot their paths and finally launch them. Obviously this game is meant to be fun and playable, whilst staying semi-realistic. Because of this I've over exaggerated the physics and accelerated time slightly.
My problem is that I see two choices on where to take the project:
1 • An 'unrealistic' simulation of our own solar system, with the planet's orbits and distances not completely accurate.
2 • A 'realistic' simulation of a totally different solar system with planets and moons that I create myself.
My personal feeling is that; while inaccurate position/velocity data may seem off putting, there's something about being able to launch probes and explore our solar system virtually that appeals to me. Exploring another solar system would be cool and all, but I would know it's just imaginary.
Anyone else got an opinion on this?
I'm thinking of making it a mission-planning style game, where the player gets to design probes/satellites/etc, plot their paths and finally launch them. Obviously this game is meant to be fun and playable, whilst staying semi-realistic. Because of this I've over exaggerated the physics and accelerated time slightly.
My problem is that I see two choices on where to take the project:
1 • An 'unrealistic' simulation of our own solar system, with the planet's orbits and distances not completely accurate.
2 • A 'realistic' simulation of a totally different solar system with planets and moons that I create myself.
My personal feeling is that; while inaccurate position/velocity data may seem off putting, there's something about being able to launch probes and explore our solar system virtually that appeals to me. Exploring another solar system would be cool and all, but I would know it's just imaginary.
Anyone else got an opinion on this?
I'm interested to see how you will go about this, as I work in mission analysis. On personal preference, I would use our solar system, at least as a start. Perhaps your game could do a progression of missions like...
Earth to Orbit
Earth to Lunar Orbit
Earth to other planets
Earth to a Libration point orbit
Earth to Alpha Centauri (obviously, you'd have to assume fictional propulsion capabilities for this one)
The reason I'm interested in seeing how you go about this is that mission planning is rocket science :) How simple are you planning on making it?
As an aside, I hope you plan to implement more than just chemical propulsion: solar electric and nuclear electric propulsion, nuclear thermal rockets, solar sails, magneto-plasma-dynamic (M2P2), and fusion propulsion for the ultra-exotiic missions.
Perhaps another aspect you can play off of is to give the player multiple options for power, propulsion, and science systems to accomplish a given mission, and somehow score it based on the amount of mass delivered or science achieved, or some similar metric.
Anyway, I dont mean to be overbearing, I'm just trying to suggest some things that I think could be fun. This sounds like a great idea for a game, best of luck in pulling it off.
Earth to Orbit
Earth to Lunar Orbit
Earth to other planets
Earth to a Libration point orbit
Earth to Alpha Centauri (obviously, you'd have to assume fictional propulsion capabilities for this one)
The reason I'm interested in seeing how you go about this is that mission planning is rocket science :) How simple are you planning on making it?
As an aside, I hope you plan to implement more than just chemical propulsion: solar electric and nuclear electric propulsion, nuclear thermal rockets, solar sails, magneto-plasma-dynamic (M2P2), and fusion propulsion for the ultra-exotiic missions.
Perhaps another aspect you can play off of is to give the player multiple options for power, propulsion, and science systems to accomplish a given mission, and somehow score it based on the amount of mass delivered or science achieved, or some similar metric.
Anyway, I dont mean to be overbearing, I'm just trying to suggest some things that I think could be fun. This sounds like a great idea for a game, best of luck in pulling it off.
Wow I had forgotten I posted this a week or so after I'd posted (no one had replied so I figured no one would).
I'm not too sure on how complex to make mission planning. I guess it has to be somewhat in-depth, but also fun to play. I really want to make it semi-complex though:
Satellites being designed by positioning components such as propulsion, communication, etc into it's bus. You'd literally draw out the bus shape, give it a shielding, drag and drop components into it and finally set up its cpu (either scripting it, or using some kind of drag/drop newbie GUI thing).
Propulsion being handled either manually by the user (keying in when to boost what thruster and for how long, etc) or via some kind of mission plotting wizard for beginners to use.
Transmission would also be complex but with simple wizards for beginners (one example, the 'camera' components could contain simple binary data of what its captured. The user could either script some kind of system to send them back, or use built-in wizards to do it).
I would definately do more than chemical propulsion too. Missions could require the user to set up orbiting satellites around other planets, which would require the user to design satellites with solar panels and batteries.
Progressive missions is a pretty cool idea too, and it could be helped by having a persistant research system. Once you've completed the first mission you would most of the research needed to complete the second, etc. etc.
The problem is that I'm not the greatest at physics. My extent of knowledge is high-school science, and I'm pretty much learning everything by reading stuff on the net. I'm pretty much a simple programmer who likes making games, but also has a huge interest in astronomy. I figured it'd make a kick ass little game unlike anything I've seen before.
I do think a realistic simulation of our solar system would be much better than a fictional one, it's just getting all the data I'd need and figuring out how to use it.
Falck wrote:I'm interested to see how you will go about this, as I work in mission analysis. On personal preference, I would use our solar system, at least as a start. Perhaps your game could do a progression of missions like...
Earth to Orbit
Earth to Lunar Orbit
Earth to other planets
Earth to a Libration point orbit
Earth to Alpha Centauri (obviously, you'd have to assume fictional propulsion capabilities for this one)
The reason I'm interested in seeing how you go about this is that mission planning is rocket science How simple are you planning on making it?
As an aside, I hope you plan to implement more than just chemical propulsion: solar electric and nuclear electric propulsion, nuclear thermal rockets, solar sails, magneto-plasma-dynamic (M2P2), and fusion propulsion for the ultra-exotiic missions.
Perhaps another aspect you can play off of is to give the player multiple options for power, propulsion, and science systems to accomplish a given mission, and somehow score it based on the amount of mass delivered or science achieved, or some similar metric.
Anyway, I dont mean to be overbearing, I'm just trying to suggest some things that I think could be fun. This sounds like a great idea for a game, best of luck in pulling it off.
I'm not too sure on how complex to make mission planning. I guess it has to be somewhat in-depth, but also fun to play. I really want to make it semi-complex though:
Satellites being designed by positioning components such as propulsion, communication, etc into it's bus. You'd literally draw out the bus shape, give it a shielding, drag and drop components into it and finally set up its cpu (either scripting it, or using some kind of drag/drop newbie GUI thing).
Propulsion being handled either manually by the user (keying in when to boost what thruster and for how long, etc) or via some kind of mission plotting wizard for beginners to use.
Transmission would also be complex but with simple wizards for beginners (one example, the 'camera' components could contain simple binary data of what its captured. The user could either script some kind of system to send them back, or use built-in wizards to do it).
I would definately do more than chemical propulsion too. Missions could require the user to set up orbiting satellites around other planets, which would require the user to design satellites with solar panels and batteries.
Progressive missions is a pretty cool idea too, and it could be helped by having a persistant research system. Once you've completed the first mission you would most of the research needed to complete the second, etc. etc.
selden wrote:I'd suggest realistic values for everything, but let the player accelerate time so that things don't take so long.
I don't really understand why you're thinking of this as being difficult for the solar system but not for an imaginary system.
The problem is that I'm not the greatest at physics. My extent of knowledge is high-school science, and I'm pretty much learning everything by reading stuff on the net. I'm pretty much a simple programmer who likes making games, but also has a huge interest in astronomy. I figured it'd make a kick ass little game unlike anything I've seen before.
I do think a realistic simulation of our solar system would be much better than a fictional one, it's just getting all the data I'd need and figuring out how to use it.
It's probably reasonable to simplify the orbital calculations by using Keplerian elements. Celestia has them for quite a few of the major solar system bodies in solarsys.ssc.
Some links to introductory space flight information (tutorials, etc) are available at http://www.lns.cornell.edu/~seb/celestia/#4.1.1
Does this help?
Some links to introductory space flight information (tutorials, etc) are available at http://www.lns.cornell.edu/~seb/celestia/#4.1.1
Does this help?
Selden
selden wrote:It's probably reasonable to simplify the orbital calculations by using Keplerian elements. Celestia has them for quite a few of the major solar system bodies in solarsys.ssc.
Some links to introductory space flight information (tutorials, etc) are available at http://www.lns.cornell.edu/~seb/celestia/#4.1.1
Does this help?
Damn that helps a lot, thanks. Right now I have Newtonian gravity implemented and working but it proves a pain in the ass to set up all the planets with initial positions and velocities.
I think the best way to have it work would be that planets use precalculated paths whilst the satellites use real-time gravity dependant paths. That way there are no massive amounts of calculations for complex systems. I'll take a look at those links and see what I can come up with.
dummy wrote:selden wrote:It's probably reasonable to simplify the orbital calculations by using Keplerian elements. Celestia has them for quite a few of the major solar system bodies in solarsys.ssc.
Some links to introductory space flight information (tutorials, etc) are available at http://www.lns.cornell.edu/~seb/celestia/#4.1.1
Does this help?
Damn that helps a lot, thanks. Right now I have Newtonian gravity implemented and working but it proves a pain in the ass to set up all the planets with initial positions and velocities.
I think the best way to have it work would be that planets use precalculated paths whilst the satellites use real-time gravity dependant paths. That way there are no massive amounts of calculations for complex systems. I'll take a look at those links and see what I can come up with.
That's the strategy that Orbiter (http://www.orbitersim.com) uses: solar system bodies are defined in simple config files with just orbital elements - gravity and other dynamical forces (eg air resistance) are generally only calculated for the spacecraft.
___________
ogg
___________
ogg
___________
I dunno if anyones followed the tutorial at http://www.stjarnhimlen.se/comp/ppcomp.html
I've come up with the code ( http://catpee.net/orbit_calculation.txt ):
double N, i, d, w, a, e, M, E, E0, E1, xv, yv, v, r;
//Calculate the day number from 2000
d = astro_day(add_year, add_month, add_day, add_hour);
//Orbital elements - Mars
N = 49.5574 + 2.11081E-5 * d;
i = 1.8497 - 1.78E-8 * d;
w = 286.5016 + 2.92961E-5 * d;
a = 1.523688;
e = 0.093405 + 2.516E-9 * d;
M = 18.6021 + 0.5240207766 * d;
M = rev(M);
//Calculate eccentric anomoly from mean/eccentricity
E = M + e * sin(M) * ( 1.0 + e * cos(M) );
//If it isn't accurate enough we can perform more calculations
if (e > 0.05)
{
E0 = E;
while (1 == 1)
{
E1 = E0 - ( E0 - e * sin(E0) - M ) / ( 1 - e * cos(E0) );
if (E1 - E0 <= 0.001) break;
E0 = E1;
}
}
//Compute planets true anomoly and distance
xv = a * cos(E) - e;
yv = a * sqrt(1.0 - e*e) * sin(E);
v = atan2( yv , xv );
r = sqrt( xv*xv + yv*yv );
//Find the planets position in 3D space
position.x = r * ( cos(N) * cos(v+w) - sin(N) * sin(v+w) * cos(i) );
position.z = r * ( sin(N) * cos(v+w) + cos(N) * sin(v+w) * cos(i) );
position.y = r * ( sin(v+w) * sin(i) );
The above calculating the position of mars. However when I calculate its position and compare it to Earth/Venus/Mercury it is at an odd angle and not on a similar plane to the other planet's orbits. This also occurs for all the outer planets beyond Earth which leads me to think it's my function. Anyone know how I can sort this?
I've come up with the code ( http://catpee.net/orbit_calculation.txt ):
double N, i, d, w, a, e, M, E, E0, E1, xv, yv, v, r;
//Calculate the day number from 2000
d = astro_day(add_year, add_month, add_day, add_hour);
//Orbital elements - Mars
N = 49.5574 + 2.11081E-5 * d;
i = 1.8497 - 1.78E-8 * d;
w = 286.5016 + 2.92961E-5 * d;
a = 1.523688;
e = 0.093405 + 2.516E-9 * d;
M = 18.6021 + 0.5240207766 * d;
M = rev(M);
//Calculate eccentric anomoly from mean/eccentricity
E = M + e * sin(M) * ( 1.0 + e * cos(M) );
//If it isn't accurate enough we can perform more calculations
if (e > 0.05)
{
E0 = E;
while (1 == 1)
{
E1 = E0 - ( E0 - e * sin(E0) - M ) / ( 1 - e * cos(E0) );
if (E1 - E0 <= 0.001) break;
E0 = E1;
}
}
//Compute planets true anomoly and distance
xv = a * cos(E) - e;
yv = a * sqrt(1.0 - e*e) * sin(E);
v = atan2( yv , xv );
r = sqrt( xv*xv + yv*yv );
//Find the planets position in 3D space
position.x = r * ( cos(N) * cos(v+w) - sin(N) * sin(v+w) * cos(i) );
position.z = r * ( sin(N) * cos(v+w) + cos(N) * sin(v+w) * cos(i) );
position.y = r * ( sin(v+w) * sin(i) );
The above calculating the position of mars. However when I calculate its position and compare it to Earth/Venus/Mercury it is at an odd angle and not on a similar plane to the other planet's orbits. This also occurs for all the outer planets beyond Earth which leads me to think it's my function. Anyone know how I can sort this?
Dummy,
There is a thorough Keplerian to Cartesian transformation algorithm at http://astronomy.swin.edu.au/~ahughes/c ... lerian.htm
Judging by the code you used, it looks like your position.z and position.y equations might need to be swapped around. That would explain the z component of position being so large
There is a thorough Keplerian to Cartesian transformation algorithm at http://astronomy.swin.edu.au/~ahughes/c ... lerian.htm
Judging by the code you used, it looks like your position.z and position.y equations might need to be swapped around. That would explain the z component of position being so large
Thanks Falck, that page looks like it'll come in very helpful. I figured out the problem I had before. I was using sin(i) to calculate the 3d position, forgetting 'i' was in degrees and not radians. I sorted that out and it seems to be working pretty good .
I've just run into a new problem though regarding timescales. I'm calculating all the planets and moons orbits via an algorithmn. However I'm using real time gravity to simulate the satellites movement. The problem is that it can only be sped up so much before the cpu has to spend a lot of time crunching numbers, and since it takes more than a few days to send a satellite to another planet this speeding up is near useless on large scale flights. In a true simulation this would be pretty much perfect, but since I'm trying to make a game that should be somewhat fun waiting 4 real weeks for your probe to reach saturn/jupiter etc would be a bit extreme
I was thinking of slightly downscaling the solar system time-wise by increasing the gravitational constant and moving the planets closer together. The measurements and such would still look as if it was to scale, but the time would be a lot faster
I've just run into a new problem though regarding timescales. I'm calculating all the planets and moons orbits via an algorithmn. However I'm using real time gravity to simulate the satellites movement. The problem is that it can only be sped up so much before the cpu has to spend a lot of time crunching numbers, and since it takes more than a few days to send a satellite to another planet this speeding up is near useless on large scale flights. In a true simulation this would be pretty much perfect, but since I'm trying to make a game that should be somewhat fun waiting 4 real weeks for your probe to reach saturn/jupiter etc would be a bit extreme
I was thinking of slightly downscaling the solar system time-wise by increasing the gravitational constant and moving the planets closer together. The measurements and such would still look as if it was to scale, but the time would be a lot faster
You could use Runge-Kutta integration to compute the trajectory of the spacecraft almost instantly, then when youre simulating it on its way to its desination, just interpolate the trajectory that you compute.
Granted thats more work, but that would allow you to accelerate time during the trajectory.
You may even be able to run the use accelerated time without affecting the accuracy of the trajectory.
Granted thats more work, but that would allow you to accelerate time during the trajectory.
You may even be able to run the use accelerated time without affecting the accuracy of the trajectory.
Yes. Celestia uses some sort of ephemeris function to get planet position info, and can do so very rapidly. Think of it this way, when you turn time acceleration on in Celestia, it simply checks the current simulation time, requests the planet positions at that time, and then renders the planets in those positions.
Celestia doesn't take gravity and such into account though does it? I have the planets in calculated orbits as you mentioned. It's just the satellites that people will be sending that cant really be precaculated, as it depends on where it is, what gravity fields are effecting it, what the user has planned for thrusts at certain times, etc.
No, Celestia does no gravitational calculations. It uses the "VSOP 87 theory", which is a fairly accurate polynomial series, to calculate the positions of each of the planets at a specific time. VSOP87 is quite a bit more accurate than simple Keplerian orbits, but is more complicated to implement.
You might try simplifying the calculations by reducing the number of bodies acting on the satellite and see how big a difference it makes. The smaller and more distant bodies may have a smaller effect than light pressure or the solar wind, for example, which I suspect you might not be including. Increasing the step size might also be reasonable, especially when calculating the effects of the more distant attractors. Some kind of quadratic (or higher) polynomial might be appropriate for interpolating between the points when you do a full recalculation.
Does this help?
You might try simplifying the calculations by reducing the number of bodies acting on the satellite and see how big a difference it makes. The smaller and more distant bodies may have a smaller effect than light pressure or the solar wind, for example, which I suspect you might not be including. Increasing the step size might also be reasonable, especially when calculating the effects of the more distant attractors. Some kind of quadratic (or higher) polynomial might be appropriate for interpolating between the points when you do a full recalculation.
Does this help?
Selden
selden wrote:No, Celestia does no gravitational calculations. It uses the "VSOP 87 theory", which is a fairly accurate polynomial series, to calculate the positions of each of the planets at a specific time. VSOP87 is quite a bit more accurate than simple Keplerian orbits, but is more complicated to implement.
You might try simplifying the calculations by reducing the number of bodies acting on the satellite and see how big a difference it makes. The smaller and more distant bodies may have a smaller effect than light pressure or the solar wind, for example, which I suspect you might not be including. Increasing the step size might also be reasonable, especially when calculating the effects of the more distant attractors. Some kind of quadratic (or higher) polynomial might be appropriate for interpolating between the points when you do a full recalculation.
Does this help?
Definitely some good ideas there that are a big help. An idea on top of what you said regarding distance bodies was some kind of Level of Detail on the gravity. Mars and its moons all provide gravitational forces from different points when you're flying between them, but from earth the gravitational effect could be simplified to a single force for all 3 (or even just ignored at such distances). I suspect this would greatly improve speed when I get around to adding small moons to planets such as Saturn and Jupiter.
I had been planning on implementing solar wind in a basic manner (so that people could experiment with solar wind powered satellites) but right now it's not simulated. I think I'm definitely going to have to simplify the gravity force calculations. Right now it calculates forces 100 times per second but I was thinking of dropping it to 50 or even 25. This should hopefully make a decent speed increase.
I'm currently having doubts whether I have implemented gravity as efficiently as I could have. Also I'm not completely sure on scales and units. To my understanding if I have a tiny 50kg planet being pulled by a sun, the force of the sun pulling being 100N, the planet should accellerate at 2m/sec/sec? Therefore if I'm performing 100 cycles per second, and the planet is exactly left of sun, on that single cycle the planet's velocity on the horizontal axis should increase by (2 / 100)m/sec?
Something interesting I noticed on my small scale simulations; I had a planet orbiting a sun in an elliptical orbit. It would rotate around its orbit following its path permanantly (or at least the 8 or so hours I left it). I then restarted and introduced another planet of smaller mass 3 or 4 times the distance out. I left this simulation running, came back hours later and noticed that the original inner planet had very slowly spiralled inwards and collided with the sun. Is this correct?
-
- Developer
- Posts: 1863
- Joined: 21.11.2002
- With us: 21 years 11 months
Seems unlikely, doesn't it? Otherwise the solar system would be unstable.dummy wrote:I left this simulation running, came back hours later and noticed that the original inner planet had very slowly spiralled inwards and collided with the sun. Is this correct?
I guess there's something odd about how you're computing the force vector on the components of the three-body system - is it possible the planetary interaction isn't coded properly, so only one planet feels the gravity of the other? Or do you have an unrealistically high mass for one or both of the planets?
(Your computation of units is correct, BTW.)
Grant
granthutchison wrote:Seems unlikely, doesn't it? Otherwise the solar system would be unstable.dummy wrote:I left this simulation running, came back hours later and noticed that the original inner planet had very slowly spiralled inwards and collided with the sun. Is this correct?
I guess there's something odd about how you're computing the force vector on the components of the three-body system - is it possible the planetary interaction isn't coded properly, so only one planet feels the gravity of the other? Or do you have an unrealistically high mass for one or both of the planets?
(Your computation of units is correct, BTW.)
Grant
The only thing I can think of is that the bodies are too close to each other. I was using pretty unrealistic masses though at a very small scale (the sun was only 5000kg) with the planets close enough to have 3 - 10 second orbit periods, maybe it was just this. If anyone's pretty good at c/c++ and wants to take a look at the function that calculates the gravitational force on a point in space, I've uploaded the function to http://games.paradum.com/gravityfunction.txt . It uses a class vector which is basically 3 doubles 'x,y,z'. If you need any more info on the functions variables let me know and I'll explain it in more detail.
Hi,
You might want to take a look at Orbiter and see how the various problems you are running into were handled. It seems to be close to what you are designing.
Cheers,
Rolf
Orbiter: http://www.medphys.ucl.ac.uk/~martins/orbit/orbit.html
You might want to take a look at Orbiter and see how the various problems you are running into were handled. It seems to be close to what you are designing.
Cheers,
Rolf
Orbiter: http://www.medphys.ucl.ac.uk/~martins/orbit/orbit.html