To be honest, this question really stumped Hao Yun.
After reading the question for a long time, he was stunned and couldn't type out a single line of code.
Optimizing code for "Glacier Engine"
Improve engine operating efficiency by ten percent
Speaking of which, he hasn’t even seen what the underlying code of this engine looks like...
At the same time, backstage at the game.
At the request of Academician Zhan Yongshu, the staff brought up the screen of contestant No. 101.
Looking at the fourth question that appeared on the screen, Professor Zhang Cunhao, who was standing next to Academician Zhan, smiled and shook his head, saying in a regretful but unsurprising tone.
"I didn't expect that he actually chose the fourth question. It seems that he is completely out of luck."
"Oh?" Academician Zhan Yongshu raised his eyebrows with interest.
"Teacher, you won't forget that before I returned to Shuimu University to teach, I worked in a front-line position in the software research and development department of Longwei Group, right?" Professor Zhang Cunhao said jokingly.
"I haven't read the specific content of the question yet. Is this Glacier Engine also a product of your department?"
"That's not true. The product itself was developed by an acquired R&D team. However, our software R&D department has optimized this product. The current Glacier 3.0 is the product after our secondary optimization. Now the mainstream large-scale 3D Action games, especially in the third-person category, are basically made with this engine!" Professor Zhang Cunhao said, with a touch of pride on his face.
However, he does have something to be proud of.
Longwei Group is a giant in Xia Guo's electronics industry, and its huge software research and development team is one of the factors that laid this foundation. Even though video games are a new thing that only appeared after the New Era, no software engineer despises them because of this.
Professor Zhang Cunhao’s meaning is very clear.
Compared with the other three questions that have no set acceptance criteria for results, this question with clear requirements for performance improvement is absolutely impossible to complete!
Because this is the fruit of the hard work of countless software engineers!
Because this is the product after countless optimizations!
Because this is the most concise code!
It's like a work of art, not a single letter is superfluous!
Not to mention the students sitting here, even the main examination committee standing here would find it almost impossible to solve this fourth question in just three days.
Of course, it is still possible to do it with a longer meeting.
"To be honest, is it inappropriate for a question like this that even you feel helpless to appear in a competition for college students?" Academician Zhan Yongshu glanced at Professor Zhang Cunhao and said.
Professor Zhang Cunhao smiled and said: "Isn't it customary to set up a trap question among the four questions in previous competitions? This is also to test the seriousness of the contestants about their objective situation. I believe that if you use your brain a little, you can think of this kind of commercial application. There is little chance of optimizing already mature software.”
Academician Zhan Yongshu laughed and said nothing.
He can probably guess a little bit about the reason why this kind of question is used as a trap question.
One is, of course, as Professor Zhang Cunhao said, it is a common practice in the Hope Cup competition to include one question among the four questions to bury people. As for the second one, I’m afraid it’s also related to the fact that Longwei Group gave a lot of sponsorship fees.
After all, for a national event like the Hope Cup that attracts the attention of countless college students and professionals, no one has made the last big question. This is an incredible stunt in itself.
Using this gimmick for promotion is more topical than any hard advertisement.
Thinking that the entire examination system for this competition was sponsored by Longwei Group for free to the organizer, Academician Zhan Yongshu didn't say anything, but he didn't have much hope for the player on the screen.
After all, even if he did it himself, he might not be able to improve the performance of the Glacier 3.0 engine by ten percent in three days. Thinking about it from another perspective, if there was such an easy way to do it, the Glacier Engine development team and the software engineers responsible for optimizing the engine must have thought of it long ago.
Choosing research topics that you are good at and avoiding those that are obviously a waste of time and energy are also essential qualities for a programmer.
If you can't do this...
In this game, player No. 101 has gone far!
…
Hao Yun didn't know that he had only spent a short time reading the questions, but several industry bosses standing in the backstage of the examination room not far away had already foreseen his ending.
Is this really the end of it
Hao Yun had thought so pessimistically at first.
After all, after he quickly went through the entire glacier engine code, it took a lot of effort just to understand it.
"First of all, you have to calm down..."
"Then, you have to figure out the logic of how this engine works."
Making graphics data output faster and with higher quality is an important criterion for a good engine. Presumably before putting this engine online, the developers of Glacier Engine have racked their brains to optimize its code.
It is not impossible to improve on the previous efforts, but if you expect to do it by one person in just three days, I am afraid that your own system plug-ins will need to be strengthened.
in this case…
It is almost impossible to optimize the code of the engine itself.
My only hope lies outside the code of the engine itself.
For example, those low-level functions that are called frequently
Whether it is a 3D engine or a 2D engine, whether it is the popular domestic "Glacier" or the more popular "Wasteland" abroad, in the final analysis, all game engines require frequent calls to underlying functions. The lower the underlying functions, the more frequently they are called. .
Especially 3D graphics rendering!
Sometimes players experience lag when encountering large scenes, or even characters hanging in the air or passing through walls. In fact, a large part of the reason is that the speed of the graphics algorithm cannot keep up.
If the underlying function could be optimized...
Maybe I really have hope of solving this problem
For a moment, Hao Yun was startled by his crazy thoughts.
Damn it
He carefully calculated it in his mind. This seems to be more difficult than optimizing the Glacier Engine!
After all, the Glacier Engine is still a product after the first year of the New Calendar, but the underlying functions called by the Glacier Engine were developed before the People's Union era.
but…
What if it works
After swallowing, Hao Yun, with the idea of giving it a try, found the math.c file in the code folder in the Glacier Engine directory, and opened a large number of called functions stored in it.
It is obviously unrealistic to read all these codes from beginning to end, but Hao Yun did not intend to do such a stupid thing.
He only needs to find the functions that are called the most frequently by this engine at runtime, are called almost every time a game scene is loaded, and are enough to affect the engine's operating efficiency, and then look for opportunities for improvement there.
Soon, Hao Yun locked a function named Q_Sqrt.
This function looks unremarkable on the surface. It is just an algorithm for finding the reciprocal of the square root using Newton's iteration method.
However, what is interesting is that during the operation of this engine, there are an outrageous number of situations where the reciprocal of the square root is required.
So from another perspective, the operation speed of this function is enough to affect the efficiency of the engine itself.
This is like a screw on a space rocket. On the surface, the speed of the rocket does not depend on the screw itself, but on the design of the rocket engine and key fuel, etc. But when the design of the rocket engine and fuel technology They have all reached a bottleneck. If we want to further improve the efficiency of rockets, we can only start researching on the basic materials.
What Hao Yun is doing at this moment is something similar.
However…
Although the idea has been found, it is not easy to follow this path.
So far, there is nothing worth digging into. After all, Newton's iteration method itself is already a very excellent mathematical method for finding the reciprocal of square roots.
Want to innovate again
It is almost impossible to improve mathematically!
If you want to go faster than this, I'm afraid you can only achieve it by building a huge database of input values and output values.
However, building a library for just a function seems to be putting the cart before the horse...
Time passed by, and Hao Yun still hadn't typed a single line of code on his computer.
Academician Zhan Yongshu, who was watching in the background, sighed softly, with a hint of disappointment in his eyes.
It's obvious that player No. 101 has fallen into a difficult situation. If he cannot change his strategy immediately and change a question, his progress will be far behind other players!
At least what they saw was that there were already three seeded contestants who had advanced the progress of the other three questions to a quarter.
"Although courage is commendable, there will be no results if this continues," Professor Zhang Cunhao said with a smile, "I just looked around and it seems that he is still studying the fourth question."
"It's very problematic if this kind of question appears in a competition," Academician Zhan Yongshu shook his head, "We can't do this in the next competition."
Professor Zhang Cunhao smiled awkwardly and coughed lightly: "Definitely next time."
However, just when both of them thought that Contestant No. 101 had no hope, Hao Yun, who was sitting at the computer desk, suddenly moved.
But, his operation seems a little weird
I saw that he was not in a hurry to write any code, but directly deleted the code about the Q_Sqrt function in the math.c file.
"What does he want to do?"
Looking at Hao Yun's operations on the screen, Zhang Cunhao was surprised by the player's mysterious movements.
He could probably guess what this player was planning to do, which was simply to redefine the "inverse square reciprocal" algorithm. However, is it possible that there is an algorithm in this world that is simpler than Newton's iteration
By the way, this is no longer the domain of programming, but the domain of mathematics, right
Dean Zhan Yongshu was also surprised, and for a moment he didn't understand what Hao Yun was planning to do. It wasn't until he saw a line [i=0x5f375a86-(i》1)] appearing on the screen that he slightly contracted his pupils.
"I might know what he's trying to do."
"…?"
Zhang Cunhao looked confused and looked at his teacher, trying to find an answer.
However, Academician Zhan Yongshu had no intention of answering his confusion. He just touched the stubble on his chin and nodded approvingly at the code on the screen.
"Wonderful..."
"It's really wonderful!"