Unpredictable but adequate bot in games

The story will be about 2D games from a third party (top view). These are mostly shooters, but the strategy will also be affected. For ease of comparison and understanding, we will take our favorite kittens. Yes, yes, it is cats that will help us well in this.

So, how do we see the usual behavior of bots in games? For clarity, we will consider a couple of examples (Fig. 1).

Fig. 1 Left - SAS Zombie Assault 3 and right Ninjago .

Pros and cons

1. In a couple of rounds, the bot trajectory becomes predictable. Victory becomes easy.
2. You can "circle" the bots and always remain unscathed. Gamers even have such a concept as "Waltz Swirl".
1. In a couple of rounds it becomes not interesting to play with bots. Continuing to play for points and rewards, the bot ceases to be an adversary.

I won’t begin to grind all the advantages or disadvantages, I think everyone understands that such a bot is not an adversary. Yes, you can complicate the level by adding 1000 of these bots and reduce ammo. Or put in a confined space, where you do not particularly run. But the essence does not change. Developers complicate the conditions, but not like an adversary. From a development point of view, this is simpler and easier.

Let's analyze the tactics of such bots on the fingers.

Fig. 2 The picture is divided into 4 frames.

1. In the first frame, we see a bot and a player standing against each other. To clarify: we control the player, the bot - program code.
2. In the second frame, the bot, not seeing obstacles, starts firing at the player.
3. In the third frame, the bot faces an obstacle and has to go around it, because it cannot shoot through an obstacle.
4. And finally, the fourth frame, the essence is the same, only there are many obstacles and the bot has to constantly change the trajectory to achieve the goal. Orange is not in vain highlighted the "visibility" of the bot. Since the bot does not have intelligence, the developer immediately tells him his task. The subtask in our case is the movement to the object.

So we figured it out. The main task is to reach fly, crawl, jump to the target, the additional choose the optimal path. Many principles in nature work with these principles, but I decided to choose an object that is more ideal in my opinion - CAT . Although the cat is far superior to the bot, they have the same principles.

Characteristics of the object "Cat"

Fig. 3 Random movements

Unplanned goals, random, but at the same time accurate movements and, finally, tactical thinking.

From life observations, a cat will never go through a puddle or try to jump onto an object that is above 4 floors. The cat sees well in the afternoon and in the dark, but in no way “through” his favorite boxes. Hiding when danger occurs during hunting or from hopelessness.

Now, we can apply this to our bot, thereby improving its characteristics and changing predictability, and hence complexity!

I think to drive such a bot, even in a closed room it will become much more interesting.

Improving performance

Visibility zone - the bot should not initially see its enemy, visibility should be limited not only to the "fog of war", but also to the objects that surround it. Fig. 4. Moreover, in the first frame, the bot immediately sees the player even through objects at any distance. On the second frame, its review is limited and the bot tries to “probe” with a glance at the search for a target. The bot has to perform sub-tasks in order to find a player.

Fig. 4 Visibility

zone Comfort zone- the bot will go to the breach at all costs until it kills or is not killed. It should not be like that. If the bot understands that his life is coming to an end, then he must hide. Or the forces, for example, are not equal, again I have to find shelter. Fig. 5. On the first frame, the bot classically thinks that it is Rambo, on the second frame, the bot tries to increase its chances of survival.

Cats love the comfort zone very much, therefore they always avoid collisions with foreign moving obscure bodies.

Fig. 5. Comfort

Zone- hit by a bullet (knife, grenade), one of the interesting tasks of players and bots. Let's say in Battlefield 3 they made such a cool effect as suppression, bullet trajectory and damage power. Thus, one and the same weapon cannot be killed at different distances in different shooting modes. In Counter Strike, this is not possible, except for the spread of bullets ...

Fig. 6 Left Battlefield 3 and right Counter Strike

But these are already more powerful games compared to those we are talking about. Nevertheless, we can take at least elementary examples. The affected area should be limited. For example, objects and objects and most importantly range. The figure below shows the farther the enemy, the less bullets will hit him. I understand that it all depends on the weapon, but this is the subtlety of the game.

As I said above, the cat will not jump higher than what he is capable of, even if he is sure that he will jump. Exception: cats with the number of lives> 6

Fig. 7 Scale of defeat of the opponent.

Waiting area - well, everything is simple, bots are usually worn as headless in order to find a target, so the player just has to sit and wait. Predictably. But in the same "Contra" bots sit out! But the camper bot is already a surprise for the player.

A cat 90% of its life is in download and standby mode. Perhaps this saves him from random acts.

Trajectory of movement- if you imagine the situation that the bot has the ability to bypass the subject, then why it does not have the opportunity to jump over it? Here the question is already to the subtleties of the game ... but no one excluded the alternative to the passage. See the picture below. The first frame shows the classic bot selection of the upper aisle, because it is closer. In the second frame, our bot selects the bottom one, because in the third frame the bot understands that the width of the passage is wider, which means more room for maneuvers.

Fig. 8 Trajectory of movement

Unfortunately, only Chuck Norris can calculate the trajectory of cats

You can continue to invent more and more ways, but there is only one conclusion. The bot serves in games, replacing a real person, usually a weak opponent. Thus, we will always want to play with a more serious opponent. Or maybe even a partner who is "not stupid."

Tactical maneuvers

Reconnaissance - a classic technique, upon seeing the enemy, the bot opens fire, not suspecting that there may be another enemy nearby. Or there is an opportunity to get around from the rear. How so? We look at the figure below ... Of course, this is a difficult trick, given that it remembers the location of the standing enemy No. 1, after which it goes further and remembers the location of the enemy No. 2. But no one forbade such a reception.

The cat is always on a stream, even when he sleeps, even when he thinks he is sleeping.

Fig. 8 Tactical maneuvers

Fighting spirit — if the bot had it, he would have said this: “I am alone, I am scared, there are many of us, we will defeat all. I am alone and I have a machine gun, I am John Jay Rambo! ”

Collective mode- It was always interesting why, when shooting at a real player, his partner runs to help, but doesn’t the bot? Yes, because they are autonomous from each other. Why not make them collective? It’s not necessary to go all over, it’s possible, for example, when a lonely bot encounters the same bot, it starts to stay closer to it. If a lone bot meets the company of its comrades, then everything, the team is assembled. So running around the crowd makes no sense. Hence the conclusion that this same bot will bypass from the rear, while its team makes an attack on the enemy from the front. I think everything is clear here.
Again, in a collective mode, morale rises, and they can actually go on a break, rather than individually.

Fig. 9

Cat Lure like James Bond, always alone, sometimes with pussies.

Bait- even if there is no collective mode, the bait bot can "bother" the player. The principle is as follows: he shot -> he was wounded -> he stepped back (to the side). If there is a collective mode, there may be nearby bot mates who will wait for it or just be there. The player following the bot will fall on the bait. If there are no companions nearby, then the bot is just TROLOLO.

Tasks and subtasks.

And finally, classic bots have only two modes - the main task (to go to the goal), the additional task (to avoid obstacles). I do not take into account the shooting. Since this is not a task, but a method.
If you expand the tasks and subtasks, then the bot will cease to be so predictable, cease to be a bot;)

PS: The implementation of all the above examples in the code is another question.
PS 2 .: I hope everyone understands my method of explanation.

Also popular now: