AdventureGPT: Using LLM Backed Agents to Play Text-Based Adventure Games

<p>Recently, I decided to take some time to learn how to utilize ChatGPT and other OpenAI models. Like much of the world, I had played with OpenAI&rsquo;s chat interface and had some interesting and silly conversations with ChatGPT. However, I wanted to dig deeper and really understand the development tools available.</p> <p>I have always enjoyed, but have never been any good at, text-based adventure games. There is a certain magic to being given a text prompt and using your imagination to create/explore a location. The games&#39; pure textual nature made them a natural choice for hooking up with an LLM. With that, the first iteration of&nbsp;<a href="https://github.com/oaguy1/AdventureGPT/tree/openai" rel="noopener ugc nofollow" target="_blank">AdventureGPT</a>&nbsp;was born.</p> <p>Initially, I forked a&nbsp;<a href="https://github.com/brandon-rhodes/python-adventure" rel="noopener ugc nofollow" target="_blank">Python port</a>&nbsp;of&nbsp;<em>Colossal Cave Adventure</em>&nbsp;and started hacking away at the main game loop. I was mainly interested in taking game output, feeding it to ChatGPT, and returning the resulting command to the game. Honestly, it was just some basic plumbing. In an evening, I hacked together the first version, and it was here that I became aware of something &mdash; I had no clue how to make ChatGPT intelligently interact with the game world.</p> <p>This was evident by the way ChatGPT initially tried to play the game. It used long, full sentences where the limited parser could only understand the first five letters of each word and only understood a handful of short phrases. This resulted in a lot of &ldquo;I DON&rsquo;T UNDERSTAND THAT&rdquo; and &ldquo;PLEASE REPHRASE.&rdquo; An early observer commented, &ldquo;Do you want terminators? Because this is how you get terminators.&rdquo;</p> <p><a href="https://betterprogramming.pub/adventuregpt-using-llm-backed-agents-to-play-text-based-adventure-games-be52f243866a">Visit Now</a></p>