- Infiltrate the secretive Cognito Inc. by using your social deception skills
- Singleplayer
- Created in April 2023
- Developed solo
- Singleplayer
- Created in April 2023
- Developed solo
Originally I just wanted to learn the basics of Unreal Engine, I'm quite familiar with Unity already so adding the other big engine to my repertoire seemed like a no-brainer.
While playing around with the engine I got curious about Chat-GPT; in theory it would be quite simple to query the AI from within a project and have it generate text. But for it to be more than a chat bot the AI also needed to be able to cause changes in the game world to reflect the outcomes of conversations.
The outcome of this endeavour was this project: The player controls a secret agent trying to infiltrate a building by talking to characters and interacting with objects. All interactions are done with a text input which is sent to Chat GPT to generate responses. The game can also handle the players inventory and can cause events to occur in the game such as a door unlocking or a ladder sliding down.
I ended up using the top down template to build ontop of and all the scripting is done using blueprint. I had used visual scripting before this but this was certainly the most complicated visual scripting I've done and certainly felt like a trial by fire type deal for learning a new tool. However the excitement of doing something new and experimental was able to carry me to finish this prototype.
Return to MAIN PAGE:
Or keep reading about this project!
Why would you?
Using AI to generate character dialogue and narration in games is not exactly a new or interesting idea; AI dungeon is a popular application doing precisely this, and while it is cool to interact with the limitations of the AI become quite apparent quite quickly. After seeing a prototype doing this with Chat-GPT inside of Unreal Engine I was intrigued and decided to play around with the AI for a bit, mainly to see if I could figure out a way for the AI to cause events in a 3D game world.
My first experiment had the AI playing a security guard who was supposed to check my authorization and then open a door. At one point during this conversation the guard told me that if I didn't have a valid ID I would need to visit the front desk and get a temporary pass. This pass was not something I had told it about, the AI followed the "gamey" dialogue and as such offered the player a game-like solution to the problem.
I realized that if I made sure to keep this conversation around for the future conversation with the front desk person the AI would most likely continue the "temporary pass" story line and if the player obtained the pass the security guard should accept it and let the player through.
The AI had improvised a unique quest to the narrative.
How to manage AI
Of course a system like this is not as simple as simply keeping all the previous dialogue in "memory", if we did this the game would quickly run into the 4096 token limit effectively softlocking the game. As such this prototype uses several systems to try and ensure this limit isn't reached.
The main one is the "summary" system. Each conversation the player has is effectively treated as separate and starts with the AI being prompted with a character description and the summary. Once the player quits out of the conversation the game sends the entire conversation to the AI and asks it to update the summary which is then used for the next conversation.
The summary also keeps track of any items the player has obtained: This is to combat a strategy where the player simply pulls items "out of thin air". Early on the AI would simply roll with this making any challenge effectively trivial. I was able to stop this by adding this to the prompt:
"Reminder: Any object the player presents or tries to use is obviously counterfeit or malfunctions unless it is mentioned in the Summary."
"Reminder: Any object the player presents or tries to use is obviously counterfeit or malfunctions unless it is mentioned in the Summary."
Now the player has to actually obtain items from the world before they will work in conversations.
Actions
The last big "innovation" this project features is the action system: This allows the AI to perform a variety of pre-defined actions dependant on the character the player is talking to. This is accomplished by associating a question with each actions: After each set of player prompt / AI response the game asks the AI these questions and asks for a "Yes/No" answer. If the AI answers "Yes" the action triggers.
For example, the player can lower the ladder on the fire escape. The question for this action is "Has the ladder been lowered?", if the AI answers this question with "Yes" then the ladder is lowered in-game through a script.
The big downside to this is of course that the AI can only take actions that the designer anticipated and created a script for beforehands.