How to store explored area of location? (For AI)

Hello!)

I’m trying to organize the movement of AI in an unknown location.
So far I’ve found two of the most common ways to implemen thist:

  1. Waypoints
  2. A random point in a radius, cast at a certain distance from the character

Both options are not completely suitable for my idea, so I began to think about the third one.

The concept is as follows:
AI has a vision that does not allow it to look through obstacles.
If he discovers that there is an obstacle in front of him, he determines the point behind him and marks it as “interesting.” There can be many such points. Consequently, it moves from point to point, creating new points of interest during the movement.

With such an implementation, one wants to avoid walking around one obstacle. It seems to me, it is necessary to store the explored area in the memory of the AI and, when adding a new point of interest, to check whether it falls into the already studied area or not.

How to store the exploredarea and how to check whether a new point falls inside the explored zone or not. Does Unity have any means for this?

decided to memorize all the coordinates of the angles of obstacles, build a polygon from them and make checks on the occurrence of a point in this polygon. How much is it justified? Can it be easier to implement? Since this method also raises a lot of questions for me (until I ask them, maybe respected users will prompt a simpler solution).

Or maybe I did not come from the wrong side and there are more correct ways of realizing the study of the territory by AI?

Perhaps you can store your data in a texture?
This comes to mind after seeing this Unite talk, which has a lot of cool ideas about storing data.
Hope it helps.

2 Likes

Thanks, m8. Ill try it)

If you’re only interested in navigation, you might want to use Unity’s built-in navmesh system.

Otherwise, the texture sylon suggested is really just a 2D array. However, since it’s a texture, too, you can also show it in a minimap or a debug screen to show you what the AI sees. If your texture is 128x128, then you’ll be dividing your map into a 128x128 grid. If your texture is larger, like 512x512, each cell in the grid will be smaller, and thus more accurate. When the AI detects an obstacle, determine which grid cells correspond to the obstacle’s bounds, and mark those cells as blocked.

Another way to store your AI’s representation of the map is to use a quadtree. It’s a little more complicated to implement, but it can be more memory efficient and more efficient to search.