📜 ⬆️ ⬇️

AI on the hoop: 5 useful tricks


I present to your attention my free translation, promised by Mr. Takezo in his commentary on the future of AI in GameDev.

Introduction


It's fun to watch the in-game visualization, especially if you created it yourself! However, in pursuit of this vivid impression, it is easy to forget that there is no need to visualize everything.
Below you will find a video tutorial on gameplay visualization and AI, recorded in the secret research lab AiGameDev.


Why do you need (good) visualization?



Below are five visualizations that we used to develop the prototype of the game RUSHING BASES. Pay attention to how strongly these tools helped us both at the initial stage of the project, when building the infrastructure, and at the end, to optimize the game balance.
')

Example # 1 - Grid Map




What does she show?

This demo is made on the basis of a two-dimensional grid. The map shows which zones of the game world are available and which are not. By default, locked cells are marked magenta, and available cells are not marked at all.
How it works?

This is just one large texture with grid dimensions, which is stretched to a debugging polygon. To eliminate the overlap, the vertical offset was used, while you can set the test depth, achieving a visible texture throughout the picture.
Why do you need it?



Example # 2 - Area Network





What does she show?

Fundamental representation of the game is based on groups of cells, which we call zones ( groups of cells, approx. Transl. ). Legs grow from the basics of finding a path and an influence map. The network of zones shows not only the zones themselves, but also their connection with each other.

How it works?

One copy of the circle is created, which is then drawn along the centers of each of the groups of cells (zones). The circle is scaled and gets a unique color depending on the size and zone ID. Connections between zones are drawn by splines, although I used to use arrows - they are less heavy for rendering, but more difficult to visualize. Zone labels are textures rendered by a graphics engine and placed on a world map with a vertical offset.

Why do you need it?



Example # 3 - Hierarchical Graph





What does he show?

This is a high-level search graph that is used by a hierarchical pathfinding algorithm. It is calculated on the basis of zones, but it has a special structure shown in the images above. Only the edges of the graph are shown, but the nodes can be seen.

How it works?

The graph is drawn as a set of edges. Each edge is drawn as a thin polygon, since Not all graphics drivers allow you to draw lines. Each node has a label drawn in the form of a sprite ( rectangles always turned towards the camera - there are sprites, approx. Transl. ).

Why do you need it?



Example # 4 - Influence Map





What does he show?

This visualization displays an "influence map", i.e. cost ( importance ?, significance? - approx. transl. ) each of the zones for the character in the current game situation. Part of the zones, depending on the proximity of the opposition characters, is marked in red or yellow - these are risk zones. Other zones, profitable, marked with blue or turquoise due to previous successful passes. The pictures above show both of these factors separately and in combination in the same zone of “success” and “risk” labels.

How it works?

This is also implemented, as in the case with the grid card, through the imposition of textures with the only difference that the overlay textures must be updated along with the update of the influence map.

Why do you need it?



Example # 5 - Navigation Paths





What does he show?

This visualization displays the final navigational path traveled by all the actors in the game world during the game. It is presented as a series of arrows interconnected. Each arrow is a segment of the traversed path. It is also possible to show the history of previously traveled paths.

How it works?

Arrows are also drawn using narrow polygons. The difference is that polygons must be updated each time you change navigation. Some optimizations have been implemented to reduce the required computations with dynamic navigation updates.

Why do you need it?



Conclusion


In our case, the navigation navigation visualization techniques described above were the best fit because The main task of the game is a tactical search for a path in a world with obstacles. These techniques brought many benefits in both low-level coding and high-level design of levels and behavior, as well as in various improvements and optimizations.
In general, it is very beneficial to have such visualizations for many other applications. The more time you devote to the implementation of the code, the more time it takes to create visual representations of the implemented entities. You will then say thanks to yourself for creating visualization tools!

Video, see the original article ... Approx. trans. original articles.
UPD: fixed typos and translation errors. Thanks to all the bug reporters!

Source: https://habr.com/ru/post/134615/


All Articles