Game Engine analysis (10)

Source: Internet
Author: User
Original Author: Jake Simpson
Translator: Xianghai

Part 1: Artificial Intelligence and navigation (path discovery)

Artificial intelligence (AI)
We have used nine other chapters to introduce the game engine, and now let's dive into a very interesting and important AI topic. Artificial intelligence is now becoming one of the most talked-about areas of Game Development second only to the rendering capabilities of game engines, indeed. Until about two and a half years ago, the game seems to be mainly considering how many polygon you can render, how beautiful your eyes are, and... Good... Laura's chest is so flexible... since we can now render very real breasts, the center begins to shift to what we actually do with those polygons (that is, playing games ). Because it provides you with the stimulating effect of playing games and participates in what is going on in the game world, AI is crucial in this field.

Artificial intelligence includes everything, from deciding which new brick to fall in Tetris (this largely refers to the knowledge of a random number generator) to creating a group-based strategy game, these Games interact with you and actually learn from you when you play. Artificial intelligence includes many rules. If you (as a game developer) don't spend enough time to make it work correctly, it will in turn bite your ass. So what rules should we talk about? In this way, you can better understand how complicated the AI system is. To avoid legal disputes, we will use a hypothetical game instead of a real game as an example.

Let us assume that some of our games live in the 3D world and do what they do. If you disturb their normal order, they will resist you (players ). The first thing you have to decide is what they are working on? Are they guarding something? Inspecting? Planning a party? Are you buying groceries? Are you finishing the bed? Creating a baseline for behavior is one of the work of game developers. Once you have this, you will always have something that the NPC (not a player role) or the computer-controlled 'people' can do to restore the player to do, and the interaction between the player and them should be completed.

Once we know what an NPC role needs to do-for example, it is guarding a door and patrolling a small area, the NPC must also have a 'world consciousness '. Game designers need to determine how the AI of the NPC sees the world and its knowledge scope. Will you just say "the computer knows everything is going on? This is often considered a bad thing, because it is obvious that computers can see and hear what you cannot see and hear. This is considered as cheating. Not an interesting experience. Or will you simulate his vision so that he can only respond to what he can see? This problem occurs when a wall appears, Because you start to go into the 'track' routines I mentioned in the ninth section to see if the NPC is trying to respond to people blocked by the wall. This is an obvious AI problem, but it is even more complicated when it comes to doors and windows.

When you start to increase the auditory consciousness of AI stimulation routines, this is still more complicated. However, this consciousness is one of the key "small things" that make the hypothetical game world more authentic or can remove suspense from doubt. If you have ever encountered such a thing, please raise your hand: you fought with an NPC in a gun battle, no more than an NPC, you walked around the corner and encountered another NPC still maintaining its default behavior mode, not realizing what just happened. Now the gun is a noisy thing, and the gun battle may have clearly reminded a "listener" NPC that something is going on. The trick to avoid this is to find an effective way to determine whether the distance between the sound source (that is, the launch of your weapon) is close enough to that the NPC can hear it.

The next step is the decision-making routine. What kind of behavior do you try to achieve when our patrol NPC role can hear but cannot see something? Is he looking for it? Ignore it? How do you decide what is important? Should he go or not investigate? As you can see, this will soon become very complicated. There are many ways to build code to handle these things, but it is usually a good idea to build a system that does not work for a particular NPC, but for all the NPCs, the system is based on attributes that you can create in text files other than the game engine. In this way, programmers do not need to change the AI for a given role, and if you make changes to the game code, it will be automatically applied to all roles immediately, this is a good thing in most cases.

Other world consciousness problems may emerge. For example, in this situation, two guards are standing next to each other. You have killed one with a sniper weapon, the other one is completely unaware of what has happened. Furthermore, the details of observing real-world behavior are the difference between a good game and a great game.

Let's say that you have prepared all the excitement-response part-you have scanned the world, decide that the NPC should respond to some ongoing things-He hears the player role sound-and you (Game Developer) determines what he should do for this-he will investigate. Now more complicated things are coming. How can he leave his current position and reach the place where he thinks a sound is made, instead of running into the walls like a common digital dummies and encountering furniture? Continue reading...

About the correct path-world navigation
Quick and accurate world navigation (also known as path-discovery) has recently become the Holy Grail for game developers. It seems very difficult to convince it. You need to have geographic knowledge of the local world-the wall location, steps, cliffs and edges of buildings. You also need the knowledge of objects in the world, such as furniture, automobiles, and especially other people. The final cause is the problem. We will return to this point later.

World navigation is generally divided into two areas: world navigation and local navigation. The two are actually only differences in scope, but most programmers treat them separately, because it is easier to deal with them. World navigation routines process and understand the room, door, and general geography, and calculate a path that allows a player or role to arrive at point A in the world. "It will let you go from point A to point B," which is easy to say, isn't it? It is easy to say, but it is difficult to do it. Understanding the world is a very complicated problem. I have seen many solutions I have tried. Quakeiii robots use the ground of the original map, in general, following the pre-processed map built. The pre-processor detects ground elements and marks them on the map builder, and builds a simplified map that only uses the ground. Robots don't care about walls, because they never approach them, just as they follow the map on the ground, they have designed to avoid walls being built inside.

Other methods build small nodes in the map itself, and AI can follow them. These nodes are usually built in the sight of each other. There is a connection from one node to all other nodes, and role AI can directly 'view ', so you make sure that the AI will not try to cross the wall from one node to another. If there is a door or a landing object, you can use these nodes to encode the path information in advance, so the NPC can adopt appropriate behavior-Wait for the elevator, open a door, or jump from one point to another. This is actually a system used by hereticii and used by raven in most of their other games.

About this topic, Jess crable of 3D realms currently works for Duke nukem forever:

"Navigation is a huge challenge in many aspects, mainly when there are a lot of ongoing things and some Unplanned things in the game, such as obstacles. To avoid and (or) Truly navigating to unplanned obstacles (such as another ai), AI needs to be well aware of what is happening around it. In comparison, another huge challenge is realism. If AI is showing what a player sees in real life, such as a person or a dog, it is more difficult to make it look authentic and credible. "

Then there is local navigation. We may have a path for our NPC to move from where he is in the world to where he thinks he is hearing the sound, but you cannot blindly follow this and expect the desired results. This type of path tends to be very specific to a given purpose. It is good when you run from one room to another along the corridor, but if you try to guide him through a huge room, the path node method is easy to get some seemingly strange paths. These paths are not dynamic either. Because they are pre-built, they are not easy to consider any dynamic changes in the world. The table may have been moved, the Chair has been damaged, and the walls have been destroyed. Of course, people will move. This is where local navigation is different from world navigation. It must consider the local world and navigate the NPC to traverse it. It must know the surrounding environment, the available paths, and decide which one to select.

The biggest problem in local navigation is other NPCs. Given a specific routine for finding a path, if you have more than one NPC in the same common area, they all try to reach the same location in the world, and the result is that they all have the same path easily. Then they try to move along this path, and the result is met together, and then they spend all their time trying to separate them, and once they are successfully separated, they try again to reach the target, then we can see that the same thing happened again. All of these seem very stupid, and this is not what most people want. So we need some changes in path discovery to avoid this situation, and we need some code that should be properly handled to avoid it. There are a lot of algorithms that can help solve this situation.

AI and role animation Problems
Of course, when a role walks in the world, you must completely decide what animation you want the role to play. Does it sound insignificant? No. For this topic, Chris Reed-soldier of fortuneii of Raven uses the current leader of the AI system named Lich-says:

"At this moment, I can tell you that we have the greatest difficulty in moving smoothly. It is very difficult to try to make five roles walk in the vicinity of each other in a multi-hill grass-filled jungle. It is important to make the underlying system perfect, because unless the role looks real at a lower level (avoid walls, appropriate animations), they cannot effectively express intelligence at any higher level of decision. For this reason, animation and underlying movement are the most important and difficult to implement. It does need perfection. "

So we have set our role to point B from point A. He has crossed the world by himself, avoiding obstacles on the way, playing the animation correctly, and now he is here. He saw you. What will we do next? Obviously, it is more about making decisions. He will fire you. Great. You respond to the shooting. What are you doing now? When he tried to escape, now you're going through all the same thing again.

To make these situations seem convincing, you have seen a lot of problems that must be addressed here. If you build your AI and use non-animated behavior to let the NPC execute, this can be mixed. Here are some examples of Ai In soldier of fortune. They were criticized because the bad guys did not respond to the stimulus in an appropriate way. When it is obvious that they should do so, the enemy's NPC will not scan or escape. Some problems are that they do not scan the enemy's NPC animation or let them go back because of space problems. Therefore, none of the greatest AI code in the world can solve this problem. This is all important to consider.

Do you want to know the hidden difficulties? Take a look at all my previous descriptions and try to apply them to a group of NPCs. These NPCs must talk to each other, set goals, and communicate with each other, but they do not interfere with each other. Once you do this, try the code as described above as a gamer's teammate, but do not block him in a gun battle. This is complicated now. Then it becomes fun. This is the most difficult part. Raven's Chris Reed comments on AI 'sense:

"I think feedback is a big problem for AI. If a role does not respond to changes in the surrounding environment, the game's sense of reality will be completely broken. There are many notable examples (hearing the sound of a gun, seeing a companion hit...) and some more subtle things (when two people look at each other and nod their heads as they pass through the hall ). Players are willing to accept some blunt and predictable things, but these things can easily bring the game to real life. "

And Jess crable agrees with the following:

"Balancing is very important... It is vital for players to have a great deal of fun, but there are other issues to balance. Gamers often say they want to see more real artificial intelligence in the game. However, too much realism begins to take fun away. There must be a good balance between the two. Changes and randomness are equally important-changes in behavior, and a certain degree of unpredictability within the scope of trust. "

Game Rules and natural games
In all our descriptions about AI, we use FPS. There are more than one kind of AI. What we have described is processing a set of rules in the 3D world. AI is far more than that. Often the best AI is actually very simple. It is a set of rules that players must respond to and process response (or start) actions.

Here we should deal with a terminology called "a natural occurrence game. A naturally occurring game essentially creates the rules that the game will follow, which will lead to unpredictable situations for game programmers.

For example, chess can be considered a natural game. There is a set of rules, but the game can fall into situations where various programmers cannot handle it individually. You cannot encode rules for every possible scenario. It is clear that gamers will not always face the same scenario each time. To some extent, the ongoing game situation will change according to his actions. Black and white is a perfect example of this situation, just like the Sims-the game has its own rules, but how you use and reconcile them is your own thing. In fact, you create a game while playing the game, instead of following the path that the game designer/programmer has defined for you.

It is possible to mix rule-based, natural game methods with FPS environments. In half life, some marine corps soldiers do this-they suppress fire force and flank attacks dynamically from the set rules. It looks dynamic, and to some extent it does. However, it is often not enough to have only one set of rules in the FPS world. Ry and other AI can often defeat simple rules, making it even more difficult to maintain correctness and remain interesting. So have some sympathy for those poor AI programmers. Their work is not easy.

Well, there is another chapter, and there is only one chapter left. In the final chapter, we will discuss top-of-the-head display, menu system, game customization and configuration, Game Engine copyright and construction, and finally game "mods ".

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.