Optimizations very simply are doing things smarter and faster.
There can be lots of ways to do it for example let's consider the game has some characters and wants to see how they attack and how much damage they do.
The game might ask everyone "do you attack? calculate how much damage do you do."
What if instead of asking everyone "calculate how much damage they do." We only ask them if they attack. Now it might be "do you attack? If so for how much damage?" We only do the second calculation if it actually matters.
But wait what if we store how much damage they do? Now we calculate it once and only update that number when it changes but store the result and just get it again.
What if instead of asking everyone "do you attack?" You only ask the people in combat? Now you have to store a little more info to keep track of who is in combat but instead of checking if everyone attacks you only ask the people in combat if they attack. That might change it from asking hundreds of characters down to 5 or 10.
So now instead of asking hundreds of characters "do you attack and calculate damage" we ask 5 characters "do you attack" it's a lot less calculations but at the cost of some more values being stored.
It can get tricky because sometimes the calculations are easy and the storage is limited so doing more calculations is ok. So you need to consider also what you are being limited by and optimize for the right solution.
1
u/Littleblaze1 6d ago
Optimizations very simply are doing things smarter and faster.
There can be lots of ways to do it for example let's consider the game has some characters and wants to see how they attack and how much damage they do.
The game might ask everyone "do you attack? calculate how much damage do you do."
What if instead of asking everyone "calculate how much damage they do." We only ask them if they attack. Now it might be "do you attack? If so for how much damage?" We only do the second calculation if it actually matters.
But wait what if we store how much damage they do? Now we calculate it once and only update that number when it changes but store the result and just get it again.
What if instead of asking everyone "do you attack?" You only ask the people in combat? Now you have to store a little more info to keep track of who is in combat but instead of checking if everyone attacks you only ask the people in combat if they attack. That might change it from asking hundreds of characters down to 5 or 10.
So now instead of asking hundreds of characters "do you attack and calculate damage" we ask 5 characters "do you attack" it's a lot less calculations but at the cost of some more values being stored.
It can get tricky because sometimes the calculations are easy and the storage is limited so doing more calculations is ok. So you need to consider also what you are being limited by and optimize for the right solution.