How does game “optimization” work? Are people sitting there changing lines of code to more “optimal” ones? What is “optimized”?

2.04K views

The recent The Last of Us for PC made me realize I had no idea what’s meant by “optimizing” a game.

Same with optifine in Minecraft improving performance. How do these things work to just make games use fewer resources?

In: 158

105 Answers

Anonymous 0 Comments

Computers are only really good at a few specific operations and tasks like adding, subtracting, comparing, and stuff like that because, when you get down to it, a computer only has the basic logic gates (AND, OR, XOR, NOR, NOT).

Now, you might notice that that is actually a really short list, so anything else has to be a combination of those simpler operations in some specific order. As an example, when a computer wants to multiply numbers it has a few tricks to accomplish that be doing a bunch of addition. The whole field of computer science is really just figuring out ways of combining those operations to do other things.

My go to example for explaining optimization with computers is sorting: you have a large number of index cards with numbers on them and want to put them in assending order, how optimized your method is can be measured by how many times you compare two cards with fewer being better. The worst of the basic implementations is called “Bubble Sort” which essentially finds the biggest number, removes it, and then repeats until the original pile is empty.

With software the go to methods of optimization are:

Do more than one thing at a time (Parallelization)

Don’t do things you don’t have to, especially if doing other things is important

When you have spare resources, use them to prepare the next area if possible

Design for the system that will run your software

That last one is the big problem for TLoU, what’s optimized for the PS2 and PS3 isn’t optimized for anything else and that’s a problem for making any kind of port between console and PC (Xbox less so because Microsoft has for the last few generations used very PC like hardware and software for the Xbox).

A fun video to check out if you want to see the extreme of this would be [this video by Stand Up Maths ](https://youtu.be/c33AZBnRHks), he goes into a bit of detail about how he made some slow code to answer a question and then several other people wrote more code that did the same thing faster and what their methods were.

You are viewing 1 out of 105 answers, click here to view all answers.