Chapter 197 - Episode 11: Part Two: Modern Code
Here, a swordsman and a wizard are attacking a monster. While such things do exist in this world in a certain sense, what I am picturing right now is strictly from a game.
First, let us consider a simple swordsman. A swordsman deals damage to a monster by combining their physical strength and their weapon's attack power. For simplicity, let us say their physical strength is 10, and the attack power of the weapon they wield, a longsword, is 10. The monster's HP will be 100. We will not consider defense.
Programming this straightforwardly would look like this.
============================================
10 + 10 = 20: Damage calculation
100 - 20 = 80: Monster's remaining HP
============================================
This is difficult for someone writing a program to understand. This is because the meaning of each number and equation is not intuitively clear. Moreover, the same equation must be written for every combat encounter.
Suppose the swordsman changes their equipment to a greatsword with 15 attack power, or if a "Skill Attack Power +10 Percent" ability needs to be incorporated, it would be a disaster. The room for errors to creep in is infinitely large.
This is where we use functions. We define a function called "Weapon Attack."
============================================
Function: Weapon Attack (Weapon Name) (Physical Strength)
Damage = Weapon's Attack Power + Physical Strength
Monster's HP - Damage
============================================
A swordsman's attack would then call this function.
============================================
Weapon Attack (Longsword) (Physical Strength) = 80: Monster's remaining HP
============================================
We separate the process of damage calculation as a function. For the programmer, it becomes clear what is happening. No matter how many attacks are performed, the calculation does not need to be done repeatedly. Furthermore, even if a skill is added, modifying the function will reflect it in all instances.
Next, for the wizard. Similarly, we define a function called "Magic Attack."
============================================
Function: Weapon Attack (Magic Name) (Intelligence)
Damage = Magic Attack Power + Intelligence
Deal Damage
============================================
Combat would be programmed in this way.
============================================
Monster's HP - Weapon Attack (Longsword) (Physical Strength)
Monster's HP - Magic Attack (Fireball) (Intelligence)
============================================
Up to this point, this is something that sorcery already accomplishes. However, even this has its limits. There is the risk of incorrectly inputting data such as physical strength or intelligence, or weapons and spells. Furthermore, errors can creep in, such as a warrior trying to use magic, or a wizard attempting to strike with a staff.
To avoid that, the concept of Object-Oriented Programming is to package functions and their necessary parameters as if they were the characters themselves. Abstract calculations are treated as if they were tangible entities, objects.
"Simply put, functions. We treat not only the magic seals, but also the parameters entered into the magic seals, and even the basics of how they are called, as a single unit," I said.
Maytyl tilted her head.
============================================
Object: Warrior
Name: Female Knight
HP: 100
Physical Strength: 10
Equipped Weapon: Longsword
Function: Weapon Attack
Function: Line "Kuh, kill me."
============================================
============================================
Object: Monster
Name: Orc
HP: 150
Physical Strength: 15
Equipped Weapon: Club
Function: Weapon Attack
Function: Capture
============================================
============================================
Female Knight's Attack
Orc's Attack
... ...
Female Knight "Kuh, kill me."
============================================
Ultimately, these two objects will autonomously engage in combat. They can balance commonality and individuality until the Orc wins and the Female Knight says, "Kuh, kill me."
Whether a character levels up and their attack power increases, or the weapon they use powers up, it will be automatically reflected.
"I think I am starting to understand a little. It is less like creating blueprints and more like giving instructions to a human organization, is it not?"
"Yes, that is exactly it. If previous sorcery designs were like a single artisan working with a combination of many tools, functions, then this is like forming a team of carpenters, blacksmiths, and textile workers to build a carriage."
"...For example, the purchase of each material is spontaneously carried out by the necessary person at the necessary time, correct?"
"Exactly. You delegate authority to the artisans. Within the scope of that authority, superiors do not interfere unnecessarily. Your understanding is remarkably quick, as expected."
"...That last part stings a bit, I must say. Well, I have noticed many things since coming here, but..."
For some reason, Maytyl became shy.
Putting that aside, Maytyl, who had been at the top of an organization, understood quickly. The larger an organization grows, the exponentially more decisions there are to be made. Naturally, a single leader cannot make all decisions. Ultimately, the ideal is for the leader to determine the objective and decide who to entrust with the necessary tasks.
Even if there are ten projects, it only requires ten decisions, namely appointing a manager for each. If a problem arises in a project, you only need to speak with that project's manager. That is, if you think of it simply, of course. In fact, in my previous world, this was applied to things like visualizing management through something called business process modeling.
The difficulty of difficult things is not that they are inherently difficult. Much of it simply lies in exceeding the capacity of the human brain.
"An ingenuity for the designer, not for sorcery itself... But does that not create a lot of waste? In terms of efficient magic power usage, it would be a negative, right?"
Maytyl realized the problem. In terms of magic power efficiency, there is a lot of overhead.
"Yes, such waste will occur. However, even taking that into account, if the scale of sorcery exceeds a certain point, this method becomes more efficient. With this method, individual parts can be standardized, and even more, they can be made abstract."
This is the concept of a base object.
It can be designed in the form of a base and its derivations, much like the classification of animals. For example, if we consider that all characters, whether a Female Knight or an Ogre, have HP,
============================================
Base Object: Creature
Name: X
HP: X
============================================
A base object can also be set up in a form like this. Individual objects inherit this and are derived by adding functions, skills. This can be used for job systems, monster types, and so on. Furthermore, if objects like weapons or spells are created, similar applications are possible.
If objects can hold other objects as elements, a nested structure also becomes possible. A warrior can hold a specific weapon object as their weapon. Special effects possessed by the weapon, for example, can be handled by the weapon itself. The user simply commands the weapon, "Activate effect," and a flaming sword will burn the opponent, while an ice sword will freeze them.
The management of the types and quantities of objects that can be held can be done within the warrior object. This way, restrictions like a warrior not being able to use magic can be naturally designed. Of course, it is also possible to have certain skills maintained exceptionally, for example, "Status Open."
"At the scale of the Infernal Flame... Hmm, isn't this exactly the kind of thinking suitable for the parallelization Mia was just talking about? If you bundle not only the magic seals but also the numerical values associated with them, the ease of parallelization increases. Hmm, with this way of thinking, it is even conceivable to abstract the concept of parallelization itself and incorporate it into the sorcery process."
"Ah, in fact, abstract processes can also be designed. For example, a method where only the basic parts of magic power supply, computation, and activation are made common, and the individual contents are derived to match each specific sorcery."
"I see, the flow is the same for all sorcery."
"Furthermore, since designs can be separated one by one, it has a significant effect in designs at a level involving multiple people."
"It might seem roundabout at first glance, but if we think of it this way, we can design magic of an unprecedented scale. Combined with the miniaturization of magic circuits, even overhead can be absorbed. Even just the efficiency of designing on paper has meaning. Specifically!!"
Maytyl looked at me, her eyes sparkling.
"...No, but that is where I absolutely cannot help any further."
"Wait a moment. How exactly do you achieve this separation of functions?"
I desperately gathered my knowledge to answer Maytyl's demand.
"...Rather than consolidating them closely in terms of design, it is about organizing their respective communications. Specifically, you set access permissions, designating areas only for inside the object, distinct from the whole. This way, to use a human organization analogy, the detrimental effect of 'a superior's interference' physically does not occur."
"Ricardo, you should be a bit more blessed with subordinates... Well, never mind. Mia, Noel. Let us consider how we can apply what we just discussed. Access, in circuits, is ultimately about the connection of lines, but..."
"It is the multi-layering of circuit wiring. We would hierarchize the circuits on the design schematic, and use separate layers for processing within objects and for interactions between objects," Mia said.
"Multi-layered circuits... But that is still in the realm of possibility..." Noel shrieked.
The increasingly heated discussion quickly surpassed my comprehension. Well, for magic power to flow, it does not need a closed circuit, but rather space around it.
"We will add new circuits using the method Ricardo described. We cannot change the original circuits as they are right now, but, for example, aiming is the final process, so it is suitable for being added as an attachment, much like a cartridge. Full-scale application will be a topic for next time," Maytyl said.
"That is significant. After all, our knights here still have not mastered the Infernal Flame."
"Yes, so we will concentrate on improving that."
"I see, as someone who will be entrusting my life to it, that is very welcome news."
"N-no, it is not like that. I am merely considering the feasibility as a sorcerer... Well, it is also true that if Ricardo were to depart at some strange point, my research would also stagnate. That is right, I have a proposal. I want you to convey it to Prince Craig. Me and..."
Maytyl began to say something outrageous.
"No, no, that is certainly..."
"Oh, but speed is our top priority, is it not?"
*
"It seems like we can make it work."
I said to Mia in the carriage on the way back to the Grand Duke's residence.
"Yes. ...Speaking of which..."
"What is it? If it is about the parallelization we just discussed, it is already beyond my understanding. Even if Mia were to explain it, I probably would not understand..."
"No, not about sorcery..."
"Is there some problem regarding Vinder?"
"No..."
Unusually, Mia stammered.
"Regarding this matter, have you spoken properly with Alfina-sama?"
"............"
At Mia's question, she who lived with both me and Alfina, I fell silent.
Comments (0)
No comments yet. Be the first to comment!