Trash of the Day: Monday - The human memory


The AI in TrashPatrol first and foremost acts as the enemy to the raccoon by chasing and hitting them as well as retrieving stolen goods from the trashcan. However, when the human is unaware of the raccoons, they follow their daily routine, which includes interacting with certain items. To do this, the human needs to know, where which items are, both stationary items, which cannot be moved by the raccoon or the human, as well as items that can be picked up and carried to another place by the human or the raccoons, like the collectables the raccoons need to steal. Therefore, we designed a system, which includes everything mentioned while making the retrieval of the currently needed information easy and straightforward.

Local and global items

The items, the human can memorize, are divided into two groups:

  • Local items, which can be moved around by the human and raccoons. If there were more than one AI in the level, each AI would have its own knowledge about where those items are, based on where the AI assumes the object should be like the original place of the object or where the AI has dropped the item.
  • Global items, which are static objects like furniture. The knowledge about this type of item is shared between all Ais in the level. In order to store the needed information about the item (type, location, id, interaction time, and object reference) the items have either a local or global data component, which specifies the type as well as the interaction time and registers the items information on begin play as a task in the respective data object, which acts as the human memory. Registering process local and global In addition to this data component, the global items also have a Scene Component, which acts as the Navigation Target for the human movement. For local items, their position is used as the navigation target, however it would be straightforward to exchange that with a dedicated Navigation target as used by the global items. Local DataComponent Setup On Object Global DataComponent Setup On Object

The data structures

The memory itself is stored in the Data Component of the human, which consists of 2 Unreal data assets:

  • The global data storage, which stores the information of the global items. This data asset is primarily stored in the GameMode and updated and maintained there. Once begin play is called, the data component on every AI retrieves the asset data from the GameMode and stores it. By storing this global information jointly in one place and only relaying the information, the code could be easily extended to e.g., updating information about these global items, since this could be done both globally, so that all AIs are notified about the changes, as well as locally, so that only one AI knows about the changes and the others still have the old information.
  • The local data storage stores information about the local items. In contrast to the global data storage, this storage is directly maintained by the Data Component, meaning register and update are done on every AI instead of in the GameMode. Therefore, each AI can have different information about the same object, for example, if one human picks up an item and places it somewhere else, that AI updates the position of that item, while the other humans still think that the object is at the place where the first human picked up the item. By combining these two data assets in one data component, every request to the memory can be made via the component, which searches both data assets instead of doing the requests twice. Filled human memory

Conclusion

Our goal for the memory of the AI in trash patrol was to be accessible via a single entry point as well as being extendable to more than one AI, meaning having shared knowledge between the different NPCs in the game. We achieved that by combining Unreal data assets in one component on the AI, on which the different item types register themselves. The AI maintains and updates this knowledge. If you have other ideas or approaches on how to design the memory of an AI, we would love to hear about them. -Kerstin

Get Trash Patrol

Leave a comment

Log in with itch.io to leave a comment.