The Ur-Quan Masters Home Page Welcome, Guest. Please login or register.
Did you miss your activation email?
October 08, 2024, 09:23:39 pm
Home Help Search Login Register
News: Celebrating 30 years of Star Control 2 - The Ur-Quan Masters

+  The Ur-Quan Masters Discussion Forum
|-+  The Ur-Quan Masters Re-Release
| |-+  Starbase Café (Moderator: Death 999)
| | |-+  Formulas - Need advice
« previous next »
Pages: [1] Print
Author Topic: Formulas - Need advice  (Read 2860 times)
jaychant
*Smell* controller
****
Offline Offline

Gender: Male
Posts: 432


Please visit my homepage


View Profile WWW
Formulas - Need advice
« on: March 03, 2009, 09:55:43 pm »

For a space game I am working on, I have four stats for each ship: mass, thrust, turn, and thrust_wait. These stats determine the actual performance of the ships. Currently I have in place the following formulas:

Code:
dirnum = round(16 * ((mass * 2) / (turn / 2)));
accel = round((thrust * 3) / mass) / (THRUST_WAIT_MAX - (thrust_wait + 1));
max_speed = ((thrust * 2) / mass);

But I'm not sure about them. Can someone just sort of critique my formulas? Thanks! Smiley
Logged

Please visit my homepage.
Elvish Pillager
Enlightened
*****
Offline Offline

Posts: 625



View Profile
Re: Formulas - Need advice
« Reply #1 on: March 03, 2009, 10:16:33 pm »

so, let's see - the more turn_wait you have, the faster you accelerate?
Logged

My team of four Androsynth and three Chmmr is the most unfair team ever!
My mod
jaychant
*Smell* controller
****
Offline Offline

Gender: Male
Posts: 432


Please visit my homepage


View Profile WWW
Re: Formulas - Need advice
« Reply #2 on: March 03, 2009, 10:26:07 pm »

so, let's see - the more turn_wait you have, the faster you accelerate?

You're looking at thrust_wait. There isn't a turn_wait in my game. I wanted to keep huge ships from having a large acceleration, but I couldn't think of a way that made sense, so I added that little bit in.

I really think all my formulas suck, which is why I'm asking for advice.
« Last Edit: March 03, 2009, 10:30:53 pm by jaychant » Logged

Please visit my homepage.
Elvish Pillager
Enlightened
*****
Offline Offline

Posts: 625



View Profile
Re: Formulas - Need advice
« Reply #3 on: March 03, 2009, 10:34:52 pm »

I meant thrust_wait. I'd think that more thrust_wait would give you less acceleration, not more.

also, the "dirnum" formula (whatever that is) is equivalent to the simpler: round(64 * mass / turn);
« Last Edit: March 03, 2009, 10:36:30 pm by Elvish Pillager » Logged

My team of four Androsynth and three Chmmr is the most unfair team ever!
My mod
jaychant
*Smell* controller
****
Offline Offline

Gender: Male
Posts: 432


Please visit my homepage


View Profile WWW
Re: Formulas - Need advice
« Reply #4 on: March 04, 2009, 12:22:21 am »

I meant thrust_wait. I'd think that more thrust_wait would give you less acceleration, not more.

also, the "dirnum" formula (whatever that is) is equivalent to the simpler: round(64 * mass / turn);

dirnum is the number of directions that the ship can face. Higher numbers mean slower turning.

thrust_wait is how many frames the game waits before allowing the player to thrust. Acceleration is how much speed is gained each thrust. I think I will probably take that bit out and stop the player from creating super-thrusters another way.
Logged

Please visit my homepage.
Elvish Pillager
Enlightened
*****
Offline Offline

Posts: 625



View Profile
Re: Formulas - Need advice
« Reply #5 on: March 04, 2009, 02:37:30 am »

...like making large ships not get as much thrust? Undecided
Logged

My team of four Androsynth and three Chmmr is the most unfair team ever!
My mod
jaychant
*Smell* controller
****
Offline Offline

Gender: Male
Posts: 432


Please visit my homepage


View Profile WWW
Re: Formulas - Need advice
« Reply #6 on: March 04, 2009, 03:55:27 am »

...like making large ships not get as much thrust? Undecided

Think of it this way: let's assume the propulsion happens by a series of explosions. If you increase the intensity of the explosion, it therefore costs more energy to produce each explosion, reducing the amount of explosions.

However, I think I will revert to my original plan, and make the thrust_wait also determined by a formula.

The point is not to make large ships not have as much thrust; On the contrary, the idea is that larger ships will have more thrust, because without the extra thrust, the ship would be much too slow and unwieldly to fight in deadly combat. For example, if you take my formula for the top speed with a mass of 500 and a thrust power of 2, you get a maximum speed of 1/500, which is extremely low.

I'm going to update the formulas right now, and I will soon have an update.

UPDATE: Here are the new formulas. I actually have more confidence in these:
Code:
dirnum = round(64 * (mass / turn));
accel = ((thrust) / (mass * 3));
max_speed = round((thrust * 2) / mass);
thrust_wait = round(THRUST_WAIT_MAX / mass);
« Last Edit: March 04, 2009, 04:05:34 am by jaychant » Logged

Please visit my homepage.
Alvarin
Enlightened
*****
Offline Offline

Gender: Male
Posts: 799



View Profile
Re: Formulas - Need advice
« Reply #7 on: March 04, 2009, 03:43:16 pm »

To behave more realistically, the relation of propultion parameters to mass should be squared .
Probably energy level will be constant per engine type , E(k)=(1/2)*m*V^2 .
Twice more mass , four times less speed .
Thrust is not related to mass , it's again engine property . But , as you can fit bigger engine into bigger ship , you could maybe positive tie them - more mass=more thrust .
« Last Edit: March 04, 2009, 03:59:56 pm by Alvarin » Logged
jaychant
*Smell* controller
****
Offline Offline

Gender: Male
Posts: 432


Please visit my homepage


View Profile WWW
Re: Formulas - Need advice
« Reply #8 on: March 04, 2009, 04:32:39 pm »

To behave more realistically, the relation of propultion parameters to mass should be squared .
Probably energy level will be constant per engine type , E(k)=(1/2)*m*V^2 .
Twice more mass , four times less speed .
Thrust is not related to mass , it's again engine property . But , as you can fit bigger engine into bigger ship , you could maybe positive tie them - more mass=more thrust .

When you say thrust, do you mean acceleration, thrust_wait, or max speed?
Also, when you say "propulsion", do you mean acceleration, thrust_wait, or maximum speed?

Assuming that formula would be for acceleration, I tried translating it into my game:

Code:
accel = (((1/2) * mass * (thrust ^ 2)) / 1000);

Is that what you meant? I assumed that V stood for Velocity.
« Last Edit: March 04, 2009, 04:34:24 pm by jaychant » Logged

Please visit my homepage.
Death 999
Global Moderator
Enlightened
*****
Offline Offline

Gender: Male
Posts: 3874


We did. You did. Yes we can. No.


View Profile
Re: Formulas - Need advice
« Reply #9 on: March 04, 2009, 04:33:57 pm »

Quote
Twice more mass , four times less speed .

On the other hand, momentum is the quantity that's actually conserved in this system, and it gives
dP/dt = 0 = Engine thrust + (M dV/dt)ship
Rearranging, we get
A = engine thrust / ship mass

You can use the energy formulation if instead of a time step you use a distance step. This is because momentum is force integrated in time, and energy is force integrated in position.
Using a distance step would be really inconvenient for a game, as each particle would update asynchronously. Plus, you'd need to add in an extra step to apportion the energy properly between the exhaust and the ship. All around, just use the momentum approach.

In short,
you were right the first time.
« Last Edit: March 04, 2009, 04:39:36 pm by Death 999 » Logged
jaychant
*Smell* controller
****
Offline Offline

Gender: Male
Posts: 432


Please visit my homepage


View Profile WWW
Re: Formulas - Need advice
« Reply #10 on: March 04, 2009, 04:44:53 pm »

OK, thx. Changed the formula back.

EDIT: These are the current formulas:
Code:
dirnum = round(64 * (mass / (turn * 2)));
accel = (thrust / mass);
thrust_wait = round(thrust / 5);

I took out the max_speed formula; it will be defined by the user.
« Last Edit: March 04, 2009, 06:39:41 pm by jaychant » Logged

Please visit my homepage.
Elvish Pillager
Enlightened
*****
Offline Offline

Posts: 625



View Profile
Re: Formulas - Need advice
« Reply #11 on: March 04, 2009, 09:45:57 pm »

*bows out of thread*
Logged

My team of four Androsynth and three Chmmr is the most unfair team ever!
My mod
Alvarin
Enlightened
*****
Offline Offline

Gender: Male
Posts: 799



View Profile
Re: Formulas - Need advice
« Reply #12 on: March 07, 2009, 08:54:34 am »

Yep, in space inertia would be a better parameter than just the mass. And engine parameters scientifical applications are, probably, less relevant to an arcade style game, unless you were going for a phisics game engine.
By "letting the user to define top speed" you mean the actual parameter, or if the acceleration button is pressed, the ship will go faster indefinately? The latter is more correct, again from real-world point of view... Unless I'm missing out something again Smiley
Logged
Pages: [1] Print 
« previous next »
Jump to:  


Login with username, password and session length

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!