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]

Wednesday, 20 September 2017

2D Games:

What are 2D games?

Today we have very advance technology for gaming, we have got VR, AR, 3D, 2.5D, etc. Back into the 90s where the technology for computers was not very advance, they mostly had 8-bit processors. Later on, with the advancement in technology use of 32-bit processors was adapted. 2D games can be played on any system, they just require a very few space. Now they are not so detailed like as much as 3D though. There are lot of versions in 2D too, like we say 8-bit 2D Game 16-bit 2D game, and finally 32-bit 2D Game, apparently 64bit might not be an appropriate option to be added in the list. 
Character 8 bit
Image 1: 8-Bit Art
Image 3: 32-Bit Art
     
Image 2: 16-Bit Art
    2D games are a set whole lot, that is implemented on a single plane also known as canvas. Now they deal with only X axis and Y axis, whereas the Z axis (used in 3D) is absent or we can say it today it is set as 0 (null). 2D games have a very restricted form of movement within a game. Such like moving front, back, up, down, rotation on Y-axis. As we can see, 2D art cannot provide us the detailed form of an art, like shadows, etc. this can be achieved in 2D by using multiple layers. This means multiple images with no background or transparent background are placed one or another on each other to achieve the respective goal. 

 Today, we have multiple 2D games out there, competing to other dimensional games. Back then, we didn’t have much of a competition in dimensions, but equivalently was a time of huge competition for the 2D games with multiple genres. But let’s talk about our past in video gaming. Former Nuclear Scientist Sir “Edward U Condon”, was the first to design a game, unofficial but true fact, first game name as “Nim”. It was developed on a computer with relay mechanism.  This machine used to play the game was named as “Nimatron”. 
Image 4: Nimatron

   It was Filed on April 26, 1940, but was brought into consideration by the September 24, 1940.

  In 1948, Alan Turing and David Champernowne had designed a concept of implementing a Chess game onto a machine. They also named it as “TuroChamp”. However, it failed due to lack of the machines capability. The machines during that period were not so advance to perform such complex calculations, was certainly failed due to technical issues.

  Officially the Very first game to come into public was “Bertie the Brain”, Which was brought into an Exhibition of Canada named as “Canadian National Exhibition” in the year of 1950. However, it was just a virtual form of tic-tac-toe game. Now this game was not considered the first game and was really a great example for the electronic versions of game, which can be displayed on a visual screen.

  This game got very famous, and was a point of attraction during the Exhibition, but was dismantled and never ever brought into public after that. Lack in the efforts of preserving the game made us to forget about it and was ignored and never brought up into the consideration for the existing world. 
Image 5: Bertie The Brain
  In 1958, here comes the most important incident and which is also considered a the most important and highly noted milestone for the era of gaming. “William Higinbotham” developed a game only and only for entertainment purpose. However, in past there were lot of games developed but these were made with a perspective of research, and had no mean of getting entertained. “William higinbotham” developed “Tennis for Two” on an Oscilloscope. It was dismantled after its exhibition, but rather got its important in the year of 1983 when “William Higinbotham” was interviewed for the purpose of history for the video gaming industry.

Image 6: Tennis for Two
  The people working in The Massachusetts Institute of Technology, took a very important step into developing a video game which was brought onto a computer. It was significantly a brighter step towards the evolution of video gaming. The game they Developed was in the Year of April, 1962 and the game developed was “Spacewar!”. This game was a big milestone, it was the first game to be copied and sold on computer, marking around 55 computer machines containing Spacewar! were sold.

  It was considered as the first game to gain this kind of achievement of reaching in to public wide away. It was like availability of same game at a same time at different location it was a huge invention. It was brought up and installed in to multiple American Educational Organizations, terming it as the first game ever.
Image 7: Spacewar


  Looking further into the age of 1960, development of first ever programming language name as BASIC, made the developers job easy. It also led to ease of access for the people to look into the programming part of software apparently in to gaming also. It affected a lot, gaming industry got boosted due to this technology, long years had very few games developed, but now in this era of 1968 there were number of games being developed and brought into public.

  Ralph Baer, who today is considered as “Father of Video gaming” had invented his first ever prototype of having a video gaming console at home and having able to play video games on Television. However, at that period people had a very different point of view regarding televisions. His patience paid him off, he successfully patented his work for the prototype of “Brown Box” in the year of 1968. This had a very huge impact on the gaming Industry and was apparently a new start towards a new Era of Video Gaming. 

Image 8: Brown Box
Image 9: Ralph Baer

Thank You!

Your Feedback will be always appreciated.