Wednesday, 15 November 2017

Physics and Maths in Games

Grand Theft Auto-5 physics: -


GTA V on of the most trending games in the world. It is an open world game that has multiple physics laws implemented. Most of the games deal with physics, primarily the basic physics like speed, velocity, jump, gravity, etc. However, in GTA V the physics won't replicates the real life laws and rules. The reason behind this is the size of map and other physical effects that contribute a lot to the game-play. The purpose of having such physics is because to invoke the nostalgia of feeling the game a bit real.

Image 1: - GTA V car physics.














The equations and calculations for this game were made by a GTA V player. He compared the in game speeds and the real life speed. He made it using a bike named “Hakuchou” which is a resemblance to Real life Suzuki Hayabusa, in all terms.

The person to do is known as “Belluani”. He developed the equations which was meant in a form to compare all the GTA V speeds with real life. It’s a rough sketch but still proved as an 80% accurate to the real life, he claims that the equation is more efficient and produce more precise results.

Image :- GTA V speed interpolation.


The developer of this code also created a small database i.e a small data table. This table consists a set of in game speed and comparison to real speed. This calculation can be firmly calculated by one, using this equation. The curiosity of people for comparison of in game life and a real life in what this developer brought in truth. Following is the Table created by him.

Image 3:- Speed Table.

Mathematical implementation in Simcity: -

Simcity is a City simulation game completely based on Budget. Here in the mayor i.e. player will have to always ensure profits and developments. It has the basic aspects that a city needs. The main aim of this game is earn and invest. Here some investments might prove profitable but some are non-profitable. A prime example of such factor are the City Services, these are used for the service of public and won’t generate any profits.

Image 4:- Sim City 2013.


Population calculation is the prime calculation of this game. The mathematical equation showing importance for population stands from the tax generator for the income of the city. It is also considered as a prime source of income. There is specific function declared for this named as Fudge.

Source Code 1 :- Fudge Function.

simcity.GetFudgedPopulation = function (a) {
    a = "undefined" !== typeof a ? a : simcity.gGlobalUIHandler.mLastPopulation;
    if (500 >= a)
        return a;
    if (40845 < a)
        return Math.floor(8.25 * a);
    a = Math.pow(a - 500, 1.2) + 500;
    return Math.floor(a)
};

This code terms out as in, considering the fact that ‘a’ is equal to smaller to 500 it will return the same output as ‘a’. As a situation if ‘a’ is greater than 500 but stands below 40845 then the output will be a calculates as subtraction 500 from ‘a’ which again powered by 1.2 and then finally an addition of 500 is done. Now final probability of getting ‘a’ as above 40845 then the output would be a multiplication of ‘a’ with 8.25. This is how the agents for per population value are calculated.

Image 5: - Fudged population v/s Actual population



There is an another function to display number of agents for your population. It works like if population is less than 500 then same is the count of the agents in your city. If the population arises from 501 and is below 336971 then it should calculate like 500 subtracted from population which is also powered with 5/6 and the addition of 500, the output of this is the number of agents showed on screen.  At last if the population awaits or is above 336971 then the actual number of agents would be population divided by 8.25.
This is how population is calculated in Sim City.

Image 6: Population of Game.



Maths and Physics in Euro Truck Simulator:



Image 7: Euro Truck Simulator.


Euro Truck Simulator is a Truck based Simulation game. SCS Soft develops it. The developers of this game are looking forward for realistic physics and a legit game play.
The implementation of multiple physics law such like Speed, velocity, drag, weight, etc. are calculated. The aim of the developer is to have a realistic game play.

Physics Implementation in ETS2:

There is specific set of information on ETS2 physics, as the company has set it to be confidential. Apparently, we have a different sort of calculations, which similar to the concept and can explain the proper flow physics in a game.


Braking in Game:-



Image 8: Braking in ETS2.



The braking in ETS2 is calculated on the basis of a formulae, but for this term we have a formulae of stating the equivalent force for the calculation of brakes.
It is force for the longitude Is equal to the force of braking plus force of drag plus force on the rear wheels.
Here the force of braking is calculated by, force of braking equal to negative of u multiplied by the constant force of braking
"f(braking)=-u*k(braking)".

Engine Force:-


Every engine generated a bit of force which is also termed a s torque. It is the equivalent force of the rotations. This force can be calculated on the basis of the speed of the rotation of the engine. This rotation of the engine is noted as RPM. The relation ship between this two is stated by the following image.

Image 9: hp vs rpm.


The horsepower is equal to the torque multiplied by rpm which is further divided by 5252.
"hp=torque*rpm/5252".
All this is calculated, but left is the main value the force of the engine generated i.e. acceleration power/ speed.

Acceleration:


The acceleration speed is is calculate by the following formulae,
Force of drive is equal to the unit of vector  multiplied by the torque multiplied by the gear ratio further multiplied by the differential ratio and the transformation efficiency and wheel radius.
F(Drive)=unit*Torque*gear ratio*differential ratio* transmission efficiency*Radius of wheel”.
The gear is an important factor here. It multiplies the speed for perfect value respective of torque generated and the rpm. The following image shows the relation between the torque and the gear but it is an example of Corvette.

Image 11: Torque and gear.


Maths in ETS2:


Day Cycle:


Image 12: Time scale.


This game has its own time scale. A variety of scale varying from multiple regions. There are Each region having a different time scale maths. Total there are 3 regions in the game.
The difference of each region is not that great can easily monitored. Maths of that is 3 seconds of real life is equal to the 9 minutes in the game.

Income:


Image 13: Income.



The income of maths for this game is easier.
Number of trucks generating profit and then the maintenance expenses are subtracted from that.
Eg:-  "Avg trucks income = number of truck * efficiency of income".
And further maintenance is "Avg maintenance cost= garage maintenance – the driver salary – the truck maintenance".
And finally the income will be,
"Income = Avg Truck income – Avg Maintenance".


That's it, there is more to cover in this topic, and surely will be covered in future. Thank You so much for your support.


References:

[10:36AM, 17-06-17]

[11:25AM, 17-06-2017]


Citations:-

GTA V physics:-
[10:41AM, 17-03-2017]

GTA V Speed interpolation: -
[10:49AM, 17-03-2017]

Speed Table:- 
[10:53AM, 17-03-2017]

SimCity:- 
[11:17, 17-03-2017]

Fudge Function:-
[11:27AM, 17-03-2017]

Population graph:-
[11:34AM, 17-03-2017]

Population:
[5:05PM, 17/03/17]

ETS2:
[5:07PM, 17/06/17]

Braking:
[5:37PM, 17/03/17]

Hp vs rpm: 
[9:54am, 27/03/17]

Torque and gear:
[10:20AM, 27/03/17]

Time cycle:
[10:23AM,27/3/17]

Income:
[10:26AM, 27/03/17]

No comments:

Post a Comment