# Mathematics in game making

65 replies to this topic

### #1 Marius

Marius

GMC Member

• GMC Member
• 209 posts

Posted 12 July 2011 - 05:51 AM

Lately, I have been wondering how important mathematics really is in programming games. I'm not talking about basic math like addition and square roots, but rather things that would not be taught until high school or college.

When I think about mathematics in game making, the first thing that comes to mind is trigonometric functions. I use them a lot for motion, distance calculation and wave-like effects. However, I only need the basics - I have for example never needed to know that sin(A + B) = sin(A) cos(B) + cos(A) sin(B). I can't even remember any time I needed to use tan(x)...

Another thing I've used occasionally is probability, but always on just a very basic level.

Most of the time, it seems as the things you really need, are algorithms that don't require a sophisticated understanding of mathematics, but rather just thinking the right way. Now, I know that mathematics is really broad, but for the sake of this discussion, let's think of maths as separated from algorithmic thinking. For example, you normally don't need maths to implement a fairly sophisticated sorting algorithm, but having an efficient algorithm isn't even that important all the time, since you very rarely need to sort thousands of items in a game.

Another example is pathfinding and graph theory. This is another example that often comes to mind when I hear mathematics in game making, but when I think about it, it only requires very basic knowledge of graph theory. If you know how the A* algorithm works, then that's all you need - and maybe even the simplified Dijkstra's algorithm is sufficient for most purposes.

It seems as although having a very good understanding of basic mathematics is often very helpful, you don't need advanced maths very often. Not to say that being good at maths is wasted - I'm sure at some point we will all encounter a problem that requires some special maths, but these don't happen often.

So what do you think; to what degree is advanced mathematics needed to make games?

Edited by Marius, 12 July 2011 - 05:52 AM.

• 0
MoaCube. Seriously, you should go there
Caster, a multi-platform Ogg extension

### #2 IceMetalPunk

IceMetalPunk

InfiniteIMPerfection

• GMC Elder
• 9603 posts
• Version:GM:Studio

Posted 12 July 2011 - 06:00 AM

You don't need any mathematics at all to make a game. But it's not about requirement, it's about supplement. Understanding mathematics allows you to create better games.

And you say you've never needed to use the tangent function? I guarantee you you have, you just don't know it. point_direction() is a wrapper for atan2, which is a variation on the arctangent. And inverse trig functions don't make much sense without their basic counterparts. Of course, tan(x) is really just sin(x)/cos(x) anyway, so if you've ever divided a sine by a cosine, you've used tangent even if you gave it a different name.

Mathematics in game making, if you assume all the geometric functions are wrapped by the language you're using, is mostly useful in optimization. For example, if your online game needs to download a minor update, you could download the entire new file...which would be slow. Or you can use math to compress it.

Math isn't there "because everyone uses advanced mathematics all the time". It's there because if you know it, you can create new things that you can't without understanding it. It drives technological progress and models the world, and without "advanced" math like inverse logarithms raised to imaginary powers (e^ix), even something as simple as a pendulum wouldn't be well-understood, only estimated.

-IMP
• 5

Are you an artist who likes creating original creature designs? Maybe you can help out with Elementa here! Give it a look; you might like the idea

### #3 tangibleLime

tangibleLime

Lunatic

• GMC Elder
• 2520 posts
• Version:GM:HTML5

Posted 12 July 2011 - 06:01 AM

Concepts in college-level math can be crucial to game development. Game physics comes to mind first. Then there are things such as optics, Markov chains and all sorts of neat concepts. The thing is, most of these are usually built into the game engine, which is why you don't need to know, for example, linear algebra to use a Markov chain implementation. Another example: try creating a 3D-game without using GameMaker's built in 3D functions, which do all the math for you.

In conclusion, yes. High-level math is very important to game making.

EDIT: You also may be forgetting the computer-science-ized math classes that allow you to create better, more efficient algorithms, so your end-users don't sit at their computers for 20 minutes while an array sorts. Example being using Bogosort with O(inf) versus using Mergesort with O(n log n).
• 2

### #4 xshortguy

xshortguy

GMC Member

• Global Moderators
• 4353 posts
• Version:GM:Studio

Posted 12 July 2011 - 06:10 AM

For games that are number-heavy (such as Role-playing games, MOBAs, etc), having a good idea on how the stats interact with each other is crucial to creating a balanced game. For example, a typical method of computing damage reduction multiplier from armor is to use the following formula: 100 / (100 + Armor). Although the formula for this is non-linear, the effective health is. Meaning that for every 1 point of armor your will have, it will be like their health has increased by exactly one percent. This relationship may not be obvious.

A more naive way of doing armor is to simply subtract that number of points from the damage. This typically results in an unstable combat system where either stacking damage or armor would be way to beneficial, as you'll either one-shot the enemy or be impossible to destroy.

As for advanced maths, I would say that you really don't need any of it. (For me, advanced math is anything relating to graduate level mathematics. Anything in undergraduate mathematics typically will be useful in game development in one way or another.)
• 1
Check out my Profile's About Me Page for some useful links.

### #5 tangibleLime

tangibleLime

Lunatic

• GMC Elder
• 2520 posts
• Version:GM:HTML5

Posted 12 July 2011 - 06:17 AM

As for advanced maths, I would say that you really don't need any of it.

You fail to realize that most all games require symplectic topology.
• 1

### #6 Marius

Marius

GMC Member

• GMC Member
• 209 posts

Posted 12 July 2011 - 06:22 AM

@IMP: I don't consider using arctangent the same as using tangent. I have used atan2 very much, but I have very rarely used atan just on its own. I don't think I've used a sin/cos either (though I might have), but if I did, I probably would have written tan instead.

@tangibleLime: Game physics is of course a good example, and if you want to make an advanced physics engine from scratch, you would of course need some theory to support you, but for almost all purposes, I don't think you need to know anything advanced (like using imaginary numbers to represent periodic functions), or you could survive with approximations. The same goes for 3D - I don't expect people to make their own engine.
What I'm saying is not that mathematics is not important to games. I'm not saying that people shouldn't care about maths either - understanding it would definitely help. My point is that it often seems as being very good at maths won't help you THAT much as a game developer, as long as you have a good understanding of the fundamentals.
Btw, as I mentioned, I don't consider sorting algorithms to require much math. Implementing mergesort isn't that hard. If you want, you could say that quicksort requires some work to find the best partition element, but other than that, it's mostly just algorithms. In addition, when I've been sorting things in games, I rarely sort very many elements, which means most of the time, O(n^2) algorithms like bubblesort will work.
• 0
MoaCube. Seriously, you should go there
Caster, a multi-platform Ogg extension

### #7 IceMetalPunk

IceMetalPunk

InfiniteIMPerfection

• GMC Elder
• 9603 posts
• Version:GM:Studio

Posted 12 July 2011 - 06:29 AM

@IMP: I don't consider using arctangent the same as using tangent. I have used atan2 very much, but I have very rarely used atan just on its own.

I'll create a custom banner for you saying "I PWNED IMP" if you can define "arctangent" without using or defining "tangent". (Note to those math-heads here who will no doubt find an obscure answer: I'm only asking Marius And Taylor expansions don't count, either!).

@tangibleLime: Game physics is of course a good example, and if you want to make an advanced physics engine from scratch, you would of course need some theory to support you, but for almost all purposes, I don't think you need to know anything advanced (like using imaginary numbers to represent periodic functions), or you could survive with approximations. The same goes for 3D - I don't expect people to make their own engine.
What I'm saying is not that mathematics is not important to games. I'm not saying that people shouldn't care about maths either - understanding it would definitely help. My point is that it often seems as being very good at maths won't help you THAT much as a game developer, as long as you have a good understanding of the fundamentals.
Btw, as I mentioned, I don't consider sorting algorithms to require much math. Implementing mergesort isn't that hard. If you want, you could say that quicksort requires some work to find the best partition element, but other than that, it's mostly just algorithms. In addition, when I've been sorting things in games, I rarely sort very many elements, which means most of the time, O(n^2) algorithms like bubblesort will work.

So...you're saying "game developers don't need to worry about advanced math because other game developers will worry about it for them"? I suppose that's true of anyone in any profession. "Surgeons don't need to worry about medicine because their assistants can worry about it for them." While true, it's a poor outlook on life.

-IMP
• 0

Are you an artist who likes creating original creature designs? Maybe you can help out with Elementa here! Give it a look; you might like the idea

### #8 Marius

Marius

GMC Member

• GMC Member
• 209 posts

Posted 12 July 2011 - 06:31 AM

As for advanced maths, I would say that you really don't need any of it.

You fail to realize that most all games require symplectic topology.

I lol'ed, then I felt really nerdy for lol'ing

@xshortguy: Those are interesting arguments. The formula for damage reduction is not very advanced, but I think it would require a very good understanding of maths to be able to figure out by yourself that it's a good formula to use, or even to understand that there is a weakness in subtracting the armor directly.
I'd say such things come with expereience though, and not necessarily education. If that's the case, then it seems as a waste of time to get postgraduate education. Maybe undergraduates should just get straight into game development without further education?
• 0
MoaCube. Seriously, you should go there
Caster, a multi-platform Ogg extension

### #9 tangibleLime

tangibleLime

Lunatic

• GMC Elder
• 2520 posts
• Version:GM:HTML5

Posted 12 July 2011 - 06:33 AM

Btw, as I mentioned, I don't consider sorting algorithms to require much math. Implementing mergesort isn't that hard. If you want, you could say that quicksort requires some work to find the best partition element, but other than that, it's mostly just algorithms. In addition, when I've been sorting things in games, I rarely sort very many elements, which means most of the time, O(n^2) algorithms like bubblesort will work.

I was using that as a simple example instead of hashing out some complex algorithm that does some crazy thing. Obviously sorting algorithms require very little math.
• 0

### #10 Marius

Marius

GMC Member

• GMC Member
• 209 posts

Posted 12 July 2011 - 06:36 AM

@IMP: I'm not saying tangent is overall useless, just that I hardly use it at all. Even though atan2 builds on atan which again builds on tan, atan2 seems to be a much more useful function than both tan and atan in terms of... well, usefulness. Like, if you need a hammer, then the hammer is useful - a piece of wood and some iron is not (heh, maybe a stupid analogy...).

Edit: @tangibleLime: yeah, but I haven't needed many complex algorithms that does some crazy things...

Edited by Marius, 12 July 2011 - 06:38 AM.

• 0
MoaCube. Seriously, you should go there
Caster, a multi-platform Ogg extension

### #11 xshortguy

xshortguy

GMC Member

• Global Moderators
• 4353 posts
• Version:GM:Studio

Posted 12 July 2011 - 06:38 AM

It doesn't take an advanced understanding of mathematics to understand that formula; in fact such things aren't taught in mathematics classes. Those things come from applying the mathematics that is learned in the class. No one is ever taught mathematics, they are simply introduced or nudged to it. Mathematics is something that individuals must come to realize on their own. There's often little nuggets of information that isn't always realized by even professional mathematicians.

Here's an interesting story related to this: http://www.snopes.co.../unsolvable.asp
• 2
Check out my Profile's About Me Page for some useful links.

### #12 IceMetalPunk

IceMetalPunk

InfiniteIMPerfection

• GMC Elder
• 9603 posts
• Version:GM:Studio

Posted 12 July 2011 - 06:52 AM

Here's an interesting story related to this: http://www.snopes.co.../unsolvable.asp

Wow. That's awesome . I think every professor should assign unsolved problems in their field to their students as homework--without telling them they're unsolved. Just tell them they're a bit harder than usual, but that the students can handle it given some extra time. Set them loose, and when the due date comes, let everyone know the truth and see if anyone's solved them .

-IMP
• 0

Are you an artist who likes creating original creature designs? Maybe you can help out with Elementa here! Give it a look; you might like the idea

### #13 Marius

Marius

GMC Member

• GMC Member
• 209 posts

Posted 12 July 2011 - 06:56 AM

Here's an interesting story related to this: http://www.snopes.co.../unsolvable.asp

Wow, if I had done something like that, my life would feel complete and I could die happy

By the way, if anyone has ever had a problem where they got limited by mathematics, I would love to hear about it.
• 0
MoaCube. Seriously, you should go there
Caster, a multi-platform Ogg extension

### #14 IceMetalPunk

IceMetalPunk

InfiniteIMPerfection

• GMC Elder
• 9603 posts
• Version:GM:Studio

Posted 12 July 2011 - 07:08 AM

Here's an interesting story related to this: http://www.snopes.co.../unsolvable.asp

Wow, if I had done something like that, my life would feel complete and I could die happy

By the way, if anyone has ever had a problem where they got limited by mathematics, I would love to hear about it.

Define "limited". In most cases, if I can't think of how to do something, I can find a script someone else has made for it. But I feel much more accomplished when I can figure it out on my own instead of relying on other people to do the work for me.

Case in point: FlyBox and Blastix. They're two games I made (both of which were abandoned just before they were ready to be released, unfortunately) based on moving colored blocks around to try to form groups of 3 or more of the same color. The hard part was determining these groups when the blocks could be 3 or MORE to a group, in any shape, possibly with other-colored blocks around them. I didn't know how to do it, but luckily Sinaz helped me out with a floodfill script.

If I hadn't gotten lucky enough to have Sinaz help, I'd never have been able to get that game working, since to this day his is the only ds_grid floodfill script I've ever seen for GM. And that script had some serious math in it (at least, I think; the variable names were so non-descriptive I really didn't know what was going on ) .

-IMP

Edited by IceMetalPunk, 12 July 2011 - 07:09 AM.

• 0

Are you an artist who likes creating original creature designs? Maybe you can help out with Elementa here! Give it a look; you might like the idea

### #15 xshortguy

xshortguy

GMC Member

• Global Moderators
• 4353 posts
• Version:GM:Studio

Posted 12 July 2011 - 07:19 AM

Define "limited"

First, I'll define a cluster point c of a set A. Then I'll define "limited"

A cluster point c of a set A is a point such that $V_\varepsilon \left( c \right) \setminus \{c\} \cap A \neq \varnothing$ for all $\varepsilon > 0$

For a given function $f : A \rightarrow \mathbb{R}, f$ is said to have a limit L at a cluster point c for every $\varepsilon > 0$, there exists a $\delta$ such that if $x \in V_\delta \left( c \right)$ then $f(x) \in V_\varepsilon \left( L \right)$.

Something is limited if the above limit exists.
• 0
Check out my Profile's About Me Page for some useful links.

### #16 Marius

Marius

GMC Member

• GMC Member
• 209 posts

Posted 12 July 2011 - 07:28 AM

No, xshortguy, not that kind of limited -.-'

More like you get a problem that you couldn't solve without using some "advanced" mathematical theory. Yes, I know "advanced" is very subjective, but you're intelligent, so I hope you can understand what I'm looking for even if I'm not very formally correct

I'm going to make a seminar about informatics and applied mathematics, and I have no idea how advanced I should make it, so I was thinking something related to games is a very safe bet. For this reason, it would be great to have very tangible examples.
• 0
MoaCube. Seriously, you should go there
Caster, a multi-platform Ogg extension

### #17 xshortguy

xshortguy

GMC Member

• Global Moderators
• 4353 posts
• Version:GM:Studio

Posted 12 July 2011 - 07:37 AM

There's guides out there explaining how the mechanics of various games work that users have figured out. The one that sticks out in my head is the Battle Mechanics guide for Final Fantasy Tactics, over at www.gamefaqs.com.

As for the mathematics that's extremely useful to know as a game developer [disclosure: I am not a professional game developer], I'd say that linear algebra, rotations with quaternions, and three-dimensional geometry is the most important in terms of designing a game world. Other things that are important are discrete calculus (unless you have a computer that isn't digital, although regular calculus is very similar to discrete calculus), graphs, and knowledge of elementary functions (exponential, trigonometric, hyperbolic, logarithms, polynomials, etc.).
• 0
Check out my Profile's About Me Page for some useful links.

### #18 Marius

Marius

GMC Member

• GMC Member
• 209 posts

Posted 12 July 2011 - 08:38 AM

Those are some good suggestions, I'll look into it. But again, some of those things are stuff you don't really need that often. You could maybe defend it by saying that these things are details you strictly don't need, but when you start getting good at something, you have to work with the details to improve further.
• 0
MoaCube. Seriously, you should go there
Caster, a multi-platform Ogg extension

### #19 IceMetalPunk

IceMetalPunk

InfiniteIMPerfection

• GMC Elder
• 9603 posts
• Version:GM:Studio

Posted 12 July 2011 - 09:19 AM

Those are some good suggestions, I'll look into it. But again, some of those things are stuff you don't really need that often. You could maybe defend it by saying that these things are details you strictly don't need, but when you start getting good at something, you have to work with the details to improve further.

Well, there's another relative term: "need". You don't NEED to know that 4*4=16 if you know that 4+4+4+4=16, but it helps. So what exactly are you using for your metric to measure if something is "needed"? If you say "can't make a game without it", then really, as long as you know only addition, you can make a game in GM with no further mathematical knowledge. It'll be a crappy game, but a game nonetheless.

So what kinds of systems or engines define your limit for "need"?

-IMP

Edited by IceMetalPunk, 12 July 2011 - 09:20 AM.

• 0

Are you an artist who likes creating original creature designs? Maybe you can help out with Elementa here! Give it a look; you might like the idea

### #20 TheSnidr

TheSnidr

Heavy metal viking dentist

• Global Moderators
• 3261 posts
• Version:GM:Studio

Posted 12 July 2011 - 09:49 AM

I don't know what you mean by advanced mathematics (everything beyond multiplication?), but you don't lose anything from knowing more math.
Knowing math generally makes you more free when it comes to game design. I've recently found great use of the vector math I learned at school, for example. You wouldn't be able to create this without experience with vector operations.

Vectors and quaternions are probably the most "advanced" mathematics I know though. To some they may seem really hard, to others they may seem basic. Advanced math is relative

Edited by TheSnidr, 12 July 2011 - 09:53 AM.

• 0

### #21 Marius

Marius

GMC Member

• GMC Member
• 209 posts

Posted 12 July 2011 - 09:53 AM

Well, there are some situations where multiplication is indispensible. For example, if you want to make something that pulsates, you might want to write image_xscale = 1 + 0.2 * sin(current_time / 700). In that case, you need to know about multiplication, and in addition knowing that sine gives you a wave. You also would be limited if you didn't know anything about manipulation graphs. It seems easy, but not everyone would recognize what a, b and c does in the expression a + b * sin(x / c).

Something like that, but I can't think of a more advanced example.
• 0
MoaCube. Seriously, you should go there
Caster, a multi-platform Ogg extension

### #22 @Alex@

@Alex@

GMC Member

• GMC Member
• 4705 posts
• Version:Unknown

Posted 12 July 2011 - 02:08 PM

I'll create a custom banner for you saying "I PWNED IMP" if you can define "arctangent" without using or defining "tangent". (Note to those math-heads here who will no doubt find an obscure answer: I'm only asking Marius public/style_emoticons/default/tongue.gif And Taylor expansions don't count, either!).

Damm, I wanted that banner, wait if I use Maclaurin expansion instead would that count even if it's just really a modified Taylor expansion?

On the topic at hand, I don't think "advanced mathematics" is really all that neccasary but I find things like approximating square/triangle/sawtooth waves quite useful while the ability to manipulate matrices has been invaluable to a little level edittor project I have going. Simspons Rule to approximate an integral has also been quite useful for various applications such as finding the centre of mass. Sure it isn't needed but it is very useful to know how to do some of these things.

• 0

### #23 xshortguy

xshortguy

GMC Member

• Global Moderators
• 4353 posts
• Version:GM:Studio

Posted 12 July 2011 - 02:48 PM

One can easily define arctangent without first defining tangent in the following manner:

$\arctan(x) = \int_{0}^{x} \frac{1}{1 + t^2} \; dt$

This method of defining a function isn't uncommon, as there are many other famous functions defined in terms of integrals. Elliptic integrals come to mind here.
• 0
Check out my Profile's About Me Page for some useful links.

### #24 Marius

Marius

GMC Member

• GMC Member
• 209 posts

Posted 12 July 2011 - 03:25 PM

I don't think Maclaurin series would be accepted since it more of a subset of Taylor series... it's a bit like if someone asks you for a number that's not greater or equal to zero and you give them 2 and argue that it's strictly greater than zero...
How about letting it be defined as follows:
For any a,b in R such that a > 0, let arctan(b/a) be the acute angle between the vector (a,b) and the x-axis. I think that did the trick. Also, the challenge sounded almost a bit cocky; I can easily say that arctan(x) is the inverse function of sin(x)/cos(x). Nothing wrong with that definition and I don't have to define the tangent, I can just use sin/cos everywhere, but somehow, I have a feeling you wouldn't have accepted that...

On topic: Alex, could you tell me more about you using matrices in a level editor? That sounds interesting. How much have you needed Simpson's rule? Most of the time when I do things that seem to require integrals (mostly when dealing with acceleration), I just add some value to the sum each time. Using discrete sums like that can give quite large inaccuracies, but if it just looks smooth anyway and you are aware that there is a deviation, then there is rarely a problem with not using the accurate value.

EDIT: About half of the content in the last three posts have been about defining arctan, so before this leads us further off-topic, maybe you could just give me that banner so we can be done with it?

Edited by Marius, 12 July 2011 - 03:35 PM.

• 0
MoaCube. Seriously, you should go there
Caster, a multi-platform Ogg extension

### #25 xshortguy

xshortguy

GMC Member

• Global Moderators
• 4353 posts
• Version:GM:Studio

Posted 12 July 2011 - 03:27 PM

I can easily say that arctan(x) is the inverse function of sin(x)/cos(x).

You have to be careful about this. tan(x) actually doesn't have an inverse function, since it isn't one-to-one. Same with sin(x) and cos(x). That's why the domains have to be restricted.
• 0
Check out my Profile's About Me Page for some useful links.

### #26 @Alex@

@Alex@

GMC Member

• GMC Member
• 4705 posts
• Version:Unknown

Posted 12 July 2011 - 04:01 PM

I've used Matrices in particular for rotating sections, letting a user select part of a level then an angle to rotate it by, although I suppose you could do this without knowing that you are using matrices by simplifing the method down to a simple series of sine and cosine functions. That is the most practial application though I've done other things like allowing the user to add to parts of a level together to form a new one from the values stored in Matrices as more of an experiment than anything. As for simpsons rule you only really get incorrect results when dealing with function of a degree greater than 4 which I almost never use. Meaning as long as I don't go above x^4 as an argument I get accurate results and if I could be bothered working out a script to differeniate the same function I couId compute the error. Ihave used it for finding the centre of mass and inertia for an object and for finding work done in compressing a spring ( Since the force is variable). I suppose I should just have easily have chosen values for the equations but then I would have to choose approiate approximate values for each unique object, having a script to calculate it just seems easier in the long run.
• 0

### #27 chaz13

chaz13

GMC Member

• GMC Member
• 4213 posts
• Version:Unknown

Posted 12 July 2011 - 04:16 PM

I would agree that any undergraduate mathematics is all very applicable to game development, but when you get to pure maths at degree level it's so abstract that very little of it has any real use; nevermind in game development.

Edited by chaz13, 12 July 2011 - 04:17 PM.

• 0

### #28 IceMetalPunk

IceMetalPunk

InfiniteIMPerfection

• GMC Elder
• 9603 posts
• Version:GM:Studio

Posted 12 July 2011 - 04:19 PM

I don't think Maclaurin series would be accepted since it more of a subset of Taylor series... it's a bit like if someone asks you for a number that's not greater or equal to zero and you give them 2 and argue that it's strictly greater than zero...
How about letting it be defined as follows:
For any a,b in R such that a > 0, let arctan(b/a) be the acute angle between the vector (a,b) and the x-axis. I think that did the trick. Also, the challenge sounded almost a bit cocky; I can easily say that arctan(x) is the inverse function of sin(x)/cos(x). Nothing wrong with that definition and I don't have to define the tangent, I can just use sin/cos everywhere, but somehow, I have a feeling you wouldn't have accepted that...

Such a simple answer, I should have expected it.

Oh, well, I'm a man of my word. Enjoy your banner: You may link it to your pwning post if you like .

-IMP
• 1

Are you an artist who likes creating original creature designs? Maybe you can help out with Elementa here! Give it a look; you might like the idea

### #29 Gamer3D

Gamer3D

Human* me = this;

• GMC Member
• 1819 posts
• Version:GM:Studio

Posted 12 July 2011 - 09:43 PM

Alternately, define it as the integral of [ tex ]\frac{1}{1 + x^2}[ /tex ]. NVM. Someone beat me to it.

Anyway, about the original topic of discussion: it depends on how you define mathematics. I'll start at the simplest mathematical property that comes to mind and move up.
• I'd find it hard (very close to impossible) to make any game without utilizing an equivalence relation. Even rock-paper-scissors and "Push a button to win" use this. Technically, you can make any game (Crysis included) using only this. It would require more storage space than anyone could possibly consider reasonable, but it's possible.
• Adding addition simplifies many of the games that were possible in the previous category. Same goes for subtraction, multiplication, division.
• Adding a square root allows me to easily use the quadratic formula. Now it's easy to make my bots aim at linearly moving targets.
• While we're at it, let's add in exponentiation and logarithms. Now it's easy to raise any number to any power (So I can do proper fog, exposure, and gradual multiplicative effects).
• Now let's add trigonometric functions. Sine, cosine, and tangent let me rotate things smoothly. The inverse functions allow me to put my data into a form that humans can understand better.
• Let's make a jump to complex numbers. Now I can find roots for ANY polynomial. I'll use this to make my bots aim perfectly at falling targets.
• Hmm... Turns out that from nearly the beginning, I've been using vectors. Cool.
• But wait! I could rotate groups of vectors more quickly by pre-calculating a rotation matrix. (Same goes for scaling, translation, skewing, etc)
• Hmmm. I have rotations, but I want to be able to combine them. I'll use quaternions.

The list goes on, but my point is that the more "advanced" the mathematics, the simpler and better you can make your game engine if you use it right.

The simplest game engine I've ever made used vectors, matrices, and square roots. I am reasonably sure that I avoided explicit calls to trigonometric functions, although I cannot be sure without checking. Nevermind. I think I used trigonometry for the skeletal animation, although I could safely remove that without affecting the rest of the engine.

So yeah. The more math you can use, the better you can make your game engine. Also, it's practically impossible (if not completely so) to avoid mathematics. Making a game about herding 3 pigeons into 2 birdhouses? The pigeonhole principle says that at least one birdhouse will have 2 pigeons in it. Making a game about petting tribbles? You can't comb a hairy sphere.

Edited by Gamer3D, 13 July 2011 - 06:10 AM.

• 0
Fast Priority Queues - Game Maker's priority queues are O(n). Mine do everything that Game Maker's do, but in O(log n) time.
Dual-Quaternion Skinning - Modifying vertexes in GM is slow. This simple vertex shader does the job both quickly and well.

### #30 Marius

Marius

GMC Member

• GMC Member
• 209 posts

Posted 14 July 2011 - 01:55 PM

IMP, I don't really need to brag about it in my signature. It's enough that you commend me for being right now let's just take the experience with us and be friends ^^

I would agree that any undergraduate mathematics is all very applicable to game development, but when you get to pure maths at degree level it's so abstract that very little of it has any real use; nevermind in game development.

That reminds me of a quote by Nikolai Lobachevsky. Paraphrased, it goes something like "Every abstract concept in mathematics can somehow be applied to the real world". Though I don't really think he was talking about maths in game development...
• 0
MoaCube. Seriously, you should go there
Caster, a multi-platform Ogg extension

### #31 numbers

numbers

GMC Member

• New Member
• 460 posts

Posted 15 July 2011 - 07:16 AM

Saying you don't need math to make a game is like saying that you don't need to know physics to fly in an airplane. You personally might not need it, but you're kidding yourself if you think that you could be in the situation you're in without it. The only reason you think it's unnecessary is because it's being handled for you. Ever tried designing AI for a heavily puzzle based game? Maths galore most of the time. Physics, graphical rendering, all of it reduces to mathematics. When you're doing things on a machine that stores everything in numbers, math is indispensable. If you're using GameMaker, will you need advanced math for all types of games? Probably not, but that's because GM handles a lot of things for you, but many types of games would still need that math. Are you going to need higher level math for all games? No. But if you really want to push the limit in what you can do as a game developer, then yeah, you'll probably need that higher math fairly often.
• 0

### #32 paul23

paul23

GMC Member

• Global Moderators
• 4115 posts
• Version:GM:Studio

Posted 17 July 2011 - 08:35 PM

I would agree that any undergraduate mathematics is all very applicable to game development, but when you get to pure maths at degree level it's so abstract that very little of it has any real use; nevermind in game development.

There is no "pure math at degree level"..

Mathematics is such a broad field that you'll always use it, yet you can't really name it when you use it. During my study (applied physics, aerospace engineering) I've had my fair share of mathematics. A lot I have never used outside the theoritical scope (2nd order differential equations come to mind), many parts I can't ever remember anymore, but the good thing about mathematics is that it can be considered a toolbox: the more you know about mathematics the broader your toolbox is. And the higher the chance that when you run into a problem you have the perfect tool for the problem.

Apart from the obvious cases like linear transformations (very interesting to see btw, how you can transform images with matrix manipulations), often you'll use things without realizing.

The other day I wanted to write an "xp" system. I wanted it to have a soft level cap (unfeasable high gains needed to grow levels). I made it so that the awarded xp was limited in a continous curve. Because my mathematics knowlenge I knew how to tackle this problem, and knew the steps needed to solve the problem.
• 0
Extensions
(gex; GM:Studio)
Math, logic parser; Executing user inputted code in a complete safe manner (gex/script; GM:Studio)
Extended constants; (gex/script; all versions)

Other useful information
Debugging; a task on it's own
Do's and Don'ts in gamemaker

### #33 IceMetalPunk

IceMetalPunk

InfiniteIMPerfection

• GMC Elder
• 9603 posts
• Version:GM:Studio

Posted 17 July 2011 - 10:09 PM

A lot I have never used outside the theoritical scope (2nd order differential equations come to mind)

You've really never worked with second-order differentials in aerospace engineering? No harmonic motion? Or does that not count since you usually work with the trigonometric solutions anyway?

-IMP
• 0

Are you an artist who likes creating original creature designs? Maybe you can help out with Elementa here! Give it a look; you might like the idea

### #34 coco13

coco13

GMC Member

• GMC Member
• 201 posts

Posted 18 July 2011 - 03:11 AM

Haha everyone at my school says "We dont need to use any of this math so why are we learning it." They just dont make games. I use all the math i use all the time. Yes the main type mathematics that are used are trigonometry. This is pretty much THE math you should learn if you want to make good games. I remember i had always wanted to learn what Sine Cosine and Tangent did because they are used for 3d cameras. Im glad i took trigonometry this summer. =D
• 0

### #35 paul23

paul23

GMC Member

• Global Moderators
• 4115 posts
• Version:GM:Studio

Posted 18 July 2011 - 07:09 AM

A lot I have never used outside the theoritical scope (2nd order differential equations come to mind)

You've really never worked with second-order differentials in aerospace engineering? No harmonic motion? Or does that not count since you usually work with the trigonometric solutions anyway?

-IMP

Ah yes that's when I used it, wondering why I didn't remember.

Well it strengthen my points only further, that mathematics is often used without realising.
• 0
Extensions
(gex; GM:Studio)
Math, logic parser; Executing user inputted code in a complete safe manner (gex/script; GM:Studio)
Extended constants; (gex/script; all versions)

Other useful information
Debugging; a task on it's own
Do's and Don'ts in gamemaker

### #36 Marius

Marius

GMC Member

• GMC Member
• 209 posts

Posted 18 July 2011 - 01:03 PM

Another thing to think about; suppose you have made a very complex algorithm for doing something. It seems to work in every case, but you're not sure. How would you make sure it works? Has anyone ever had a situation where they actually did a formal proof to show that something worked?
• 0
MoaCube. Seriously, you should go there
Caster, a multi-platform Ogg extension

### #37 @Alex@

@Alex@

GMC Member

• GMC Member
• 4705 posts
• Version:Unknown

Posted 18 July 2011 - 02:21 PM

I haven't done a formal proof for anything I've created myself... Mainly because I hate doing proofs that aren't really easy.
• 0

### #38 chaz13

chaz13

GMC Member

• GMC Member
• 4213 posts
• Version:Unknown

Posted 18 July 2011 - 05:10 PM

Another thing to think about; suppose you have made a very complex algorithm for doing something. It seems to work in every case, but you're not sure. How would you make sure it works? Has anyone ever had a situation where they actually did a formal proof to show that something worked?

It's usually self evident if it works or not- and it only usually needs to work for what you're applying it to, not necessarily for every single case. You usually only need proofs as evidence to other people a finding you've made works, which is a fairly different realm to applying mathematics to games (especially as most in game mathematics is already well proven maths being applied as opposed to new ideas).
• 0

### #39 xshortguy

xshortguy

GMC Member

• Global Moderators
• 4353 posts
• Version:GM:Studio

Posted 18 July 2011 - 05:26 PM

It's usually self evident if it works or not- and it only usually needs to work for what you're applying it to, not necessarily for every single case. You usually only need proofs as evidence to other people a finding you've made works, which is a fairly different realm to applying mathematics to games (especially as most in game mathematics is already well proven maths being applied as opposed to new ideas).

That's not necessarily true. Just because it spits out a number doesn't mean that the number is right. For example, consider a program that adds up very large numbers; this could be subject to overflow errors and give a wrong result. These types of problems often limit physicists in their calculations and requires them to be careful.
• 0
Check out my Profile's About Me Page for some useful links.

### #40 Mnementh

Mnementh

15151

• GMC Elder
• 6370 posts
• Version:GM:Studio

Posted 18 July 2011 - 05:53 PM

I've written several semi-formal proofs while developing or modifying algorithms. For example, I use a modified form of Dijkstra's Algorithm to identify the area that a player can move to in turn-based tactics games. For those unfamiliar with the algorithm: Dijkstra's Algorithm is "a graph search algorithm that solves the single-source shortest path problem for a graph with nonnegative edge path costs, producing a shortest path tree". It begins with an initial cell and expands a ring of cells around it in order of distance from the start cell, until a goal condition it met. For my use, the goal condition is met when there are no more cells closer than the maximum distance. The original algorithm may identify an initial shortest path to a particular cell, and then later identify an even shorter path. I realized, through observation of my implementation, that because of the nature of the graph I was working with, my algorithm's initial path would always be the shortest. When I say "nature of the graph", I mean the particular property of the graph in a turn-based tactics game: although units move from one cell to another, the cost of that movement is dependant only on the cell that the unit is moving to, i.e. every edge leading to a particular node has the same weight.

My proof attempted do demonstrate that, given a directed graph in which every edge leading to a particular node has the same weight, Dijkstra's algorithm has found a shortest path to a node when that node is added to the open list. To do that, I assumed the opposite: that for a given graph, there was a node that was visited twice, the second time with a shorter path than the first. Because every edge leading to that node has the same weight, the implication is that the node's new parent has a shorter path than the node's initial parent. However, one property of Dijkstra's Algorithm is that nodes are expanded in non-decreasing order of distance: and thus, if the second parent had a shorter path than the first, it would have been expanded before the first, leading to a contradiction.

var open, s, range;
open = argument0;
s = argument1;
range = argument2;

var i;
for (i = 0; i < ds_list_size(s.neightbors); i += 1) {
var neighbor;
neighbor = ds_list_find_value(s.neighbors, i);

if neighbor.g > s.g + neighbor.cost && s.g + neighbor.cost <= range {
neighbor.g = s.g + neighbor.cost;
neighbor.parent = s;
ds_priority_add_or_update(open_list, neighbor, neighbor.g); // I removed this line, because the algorithm will never update a cell.
ds_priority_add(open_list, neighbor, neighbor.g); // This line was added.
}
}

• 0

### #41 Gamer3D

Gamer3D

Human* me = this;

• GMC Member
• 1819 posts
• Version:GM:Studio

Posted 18 July 2011 - 06:55 PM

Another thing to think about; suppose you have made a very complex algorithm for doing something. It seems to work in every case, but you're not sure. How would you make sure it works? Has anyone ever had a situation where they actually did a formal proof to show that something worked?

This is game making (I.E. no need for precision, and it's often better to fake things than to create a foolproof solution). Unless you're making a library for someone else to use, it's usually safe to test it on the range of conditions that you expect.

For example, a short time ago, I created a bot aiming system for an FPS (Using finite-speed projectiles, gravity possible on projectile/target/both). I had some options:
• Quartic formula (Foolproof solution)
• Quadratic formula (Works unless projectiles have gravity or the target is falling, but is much cheaper than quartic)
• Iterative solution. Guess where to aim, improve guess based on error in original guess. (There's no guarantee that this will find the best solution, especially since I'll only let it guess 4 times or so)
• Hybrid.

Long story short, I use a quadratic to find the starting point, then an iterative solution to hit falling targets. There's no proof that it'll work all the time, but if it fails, it'll just cause the bot to miss (Which is expected by most players anyway, so no harm done).
• 0
Fast Priority Queues - Game Maker's priority queues are O(n). Mine do everything that Game Maker's do, but in O(log n) time.
Dual-Quaternion Skinning - Modifying vertexes in GM is slow. This simple vertex shader does the job both quickly and well.

### #42 NikaB

NikaB

GMC Member

• New Member
• 111 posts
• Version:GM8

Posted 19 July 2011 - 06:14 AM

Well, the most basic use of "not extremly simple" mathematics is the angle calculation. In my opinion, geometry is more needed in game making than pure algebra, because you are making something which must be seen and understood.
See : If you are making a TDS and your character isn't rotating... :/
So, "complicated" mathematics are more needed (in game making) to make physics. They also allow you to operate with very high level algebra and/or arithmetic; but in my opinion it's an aspect of maths probably unused (in general) in game making.

Concerning me, mathematics is the only thing I need to learn to be more "expert" in programming. Because I'm only 8th grade, 14 years old, and the most complicated thing I can do for the moment in geometry, is the bases of trigonometry, Pythagoras, Thales etc... I'm now entering to 9th grade and I think I will really learn a LOT of stuff needed for programming.

So exciting for me !
• 0

### #43 No Eyed Fsh

No Eyed Fsh

GMC Member

• New Member
• 24 posts

Posted 06 September 2011 - 09:30 AM

In GM, knowledge of stuff like trig isn't strictly necesssery. This is because many of the things that trig is normally used for are already put into build in functions.

Take

imageAngle = pointTo(mouse_x, mouse_y);
(I'm pretty sure I got the syntax wrong)...

If you were to look at the code behing pointTo(), you would see something like this:

imageAngle = atan2((mouse_y - y) , (mouse_x - x))

• 0

### #44 drt_t1gg3r

drt_t1gg3r

GMC Member

• GMC Member
• 3658 posts
• Version:GM:Studio

Posted 18 October 2011 - 11:36 PM

EDIT: cut quotes and comments that was not related to my reply
.
.

So...you're saying "game developers don't need to worry about advanced math because other game developers will worry about it for them"? I suppose that's true of anyone in any profession. "Surgeons don't need to worry about medicine because their assistants can worry about it for them." While true, it's a poor outlook on life.

-IMP

IMP, out of the current 3 pages of replies this is the one that set me aside a bit. How can one say 'it's a poor outlook on life' when we no longer re-create the wheel? What has been done and perfected is surely done an no longer needed to recreate for no other purpose than the individual's need to do so. I understand binary a little but no longer is it a must have to create simple games. Assembly language isn't either to my knowledge. [dot]Net has libraries upon libraries that help the designer so we don't have to recreate it.
• 0

Those who can, ...do. - Those who can't, ... teach, .. or probably took an arrow to the knee.

Avatar created by Stewart. They take avitar requests here

### #45 mechlore

mechlore

GMC Member

• GMC Member
• 55 posts

Posted 19 October 2011 - 12:20 AM

Ive always been pretty terrible at math, and I created about as complex of a game as you can create in gamemaker (called MechLore, im on google now so if you google MechLore as one word you'll find it).

You would be surprised at how little advanced math you need to know to do fairly complex things with gamemaker style middleware. (ISOMETRIC) Archs for example - in my game use no math or physics but behave as though they do. Its really just a matter of applying what you do know, in this case, that every step the arching object needs to go upwards... but slow and reach 0 towards the top, before accelerating downwards again. With gamemaker you dont need to know physics, you just need to know, basically, how to move objects.

Note: Im basing this off my experience with math in highschool, I recently took a math class (that im in right now actually) and im averaging 99%, it actually feels really really easy... so.. Maybe I've always been good at math, just bad at learning it in highschool or using gamemaker has vastly improved my propensity for learning math.

Edited by mechlore, 19 October 2011 - 12:23 AM.

• 0

Thing

### #46 chance

chance

GMC Member

• Global Moderators
• 8357 posts
• Version:GM:Studio

Posted 19 October 2011 - 11:43 AM

I recently took a math class (that im in right now actually) and im averaging 99%, it actually feels really really easy... so.. Maybe I've always been good at math, just bad at learning it in highschool or using gamemaker has vastly improved my propensity for learning math.

Yes to emphasis. Game making and mathematics both expand your learning ability. They enhance creativity, logical thinking, and systematic problem solving.

Even if you don't apply mathematics directly to your games, prior study of mathematics improves your reasoning skills and lets you make better games.
• 1

### #47 MortimerInBlack

MortimerInBlack

GMC Member

• GMC Member
• 145 posts

Posted 11 November 2011 - 02:57 AM

Hey, nice topic, and I have an example for you. Write a function called "function_angle_difference(ang1, ang2)" that takes 2 angles and returns their difference (the smallest angle between them). Example: function_angle_difference(45, 100) returns 55.

But you cannot simply take the absolute value of the difference because what if the 2 angles are across the 0 degree line? As it turns out, the algorithm/math is fairly complicated. I won't write the solution here so that Maurice can try it, but the answer is here: http://www.gmlscript...ngle_difference

Who knows? Maybe there's another solution to that with a simple if/else. My point is, a simple question like "what's the difference between 2 angles?" can lead to complicated formulas. But another point is you can just use script libraries as long as you understand what they do and what restrictions they may have, because I never figured that out and just got it from GML scripts.

I've needed the angle difference function for certain AI and path finding. You can't always just use point_direction because realistic objects need to take time to turn towards a point, and you have to know how long that will take.

Anyway, I'm probably biased because I've tutored math on and off for 2 years now, plus I'm good at it, plus I appreciate my bachelor's degree in CS and the master's I am seeking now, plus other stuff I can't think of right now, such as I often write simulations of real-world things for my own enjoyment like space and orbit simulators.

The most complicated thing I've made with GM is probably that remake of Commander Keen (a 2D isometric platformer with ledge-grabbing, pole-climbing, moving platforms, and shooting in many different states on all those objects). It involved very little math. A close second would be certain space and orbit simulations, which as you can imagine involved fairly heavy math for both geometry and physics (gravity).

So my ultimate point is this: writing games and learning how to write games is about figuring out problems and how those problems work in the game language. Whether or not the problem involves advanced math or even any math at all is dependent on the problem itself. Certain genres of games will be more math-intense than others.
• 0

### #48 numbers

numbers

GMC Member

• New Member
• 460 posts

Posted 15 November 2011 - 05:07 AM

what if you want to program AI of some kind? Neural nets need math. If you want fast collision detection, the GJK algorithm definitely needs math. Typically, you don't need math if you go with the most naive algorithm you come up with, but it'll take some kind of mathematical analysis if you want to reduce the problem into a simpler one, or to create an efficient algorithm. You can't work with a system that's entirely based on numbers and then claim that you don't need math. Graph theory, bayesian probability, functional analysis, it all helps when you want to do a more complicated project. Don't assume that it doesn't count as math just because you aren't crunching numbers. Gradeschool "math" doesn't really give you a sense of the broad applications or the real nature of higher level mathematics, and you've likely touched on the basics of some of these concepts without realizing it.
• 0

### #49 ean

ean

GMC Member

• New Member
• 190 posts
• Version:GM8

Posted 27 November 2011 - 04:30 PM

My game making teacher doesn't have a math degree but after some debate they let him teach anyway. He also teaches Direct X.
• 0
VOTE FOR BUDDY ROEMER HE'S A STRAIGHTFORWARD, DOWN TO EARTH AMERICAN GUY WHO ISN'T PART OF THE BIGBROTHER CONSPIRACY

KILL NO LIVING THING

We have the worlds greatest scientist, engineers and politicians in this community with super fast computers

### #50 Desert Dog

Desert Dog

GMC Member

• GMC Elder
• 6409 posts
• Version:Unknown

Posted 27 November 2011 - 09:07 PM

I came across this article/tutorial while googling around once:
The Use of Mathematics in Computer Games
• 0
HTML5 games for mobile:
HexDogs Bugz Burn! Captain George Golfing Block Memory

Games for Androids
*NEW* Word Dog - Published by Dangerous_Dave

Code: General Array Functions - GM-S friendly. sorting, shuffling. Includes a quicksort.
Use the quicksort to sort ds_lists 10-18 times faster than ds_list_sort()!

#### 0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users