--- title: Wiesli Jonas emoji: 📊 colorFrom: green colorTo: purple sdk: gradio sdk_version: 3.21.0 app_file: app.py pinned: false --- # Documentation COMPP By Jonas Wiesli and Lea Martin K. Artificial Intelligence can be used in video games to create more intelligent and realistic characters and environments. It can also be used to improve the gaming experience by creating more challenging opponents or more immersive Worlds. Some games even use AI to create entire worlds that change and evolve. Although video games have attempted to simulate intelligence using state machines, Markov chains & similar techniques (such as NPCs in games like The Elder Scrolls V: Skyrim, Halo and The Sims), the recent emergence of large language models could potentially change the way video game narratives and even world design are implemented & presented. Since we both are interested in creating games, we decided to make our project about a game that uses a large language model to communicate between player and machine. The initial idea was to create a Role-Playing Game where the player can ask questions to a Chatbot. The theme would be centred around a crime, like a murder, and the player must find the murderer. Together we created the storyline and then split the work. The murder is set in a museum for medieval history. The victim was owner of over half the items that were displayed in the museum. There are five suspects of the murder and all of them work in the museum. Some knew the victim well, some did less. The player can ask thirty questions to find out who is guilty. There is also a floor plan to visualize the museum and check, if what the suspects are saying is correct. ## Choice of LLM Once we decided on the idea, it was time to decide which LLM we wanted to use. There were a couple of free options in the different models on Huggingface, but there were issues with consistency in the outputs, making it somewhat impossible to generate congruent dialogue. The newly released LLaMa model by Meta looked somewhat promising, but it was leaked just after the project had already started development, so its capabilities weren't as clear at the time, making it an unideal choice. We ended up settling on OpenAi's GPT model, since with their public test runs of ChatGPT were first-hand proof that this sort of project would be possible. We wanted to get access to GPT-4 due to its more robust output & better defences against jailbreaks, but unfortunately, our request was not accepted. In the end, the website uses GPT-3.5 via the API. ## Gradio I wanted to use a Gradio interface, since i hadn't used it before & wanted to try something new. Therefore, the project was realized using Python on a Huggingface space, accesing the GPT-Model via API. I had some struggles with getting the visual style correct, because there are some quirks to changing the style of the form. It was quite frustrating at some points, because the official documentation was only partially helpful. For instance, when trying to import a font from Googlefonts into a gradio theme, nothing seemed to work, even the code that was explicitly inside of the documentation. The fix was writing a couple lines of custom CSS, but I still wasted too much time on implementing something that simple. Some bugs are still present in the final release, such as the mobile site not looking great, and an odd whitespace bug when scaling the website up or down. There were also issues with passing parameters to individual components of the application, which ended up manifesting in some minor bugs like the question count not updating correctly. Overall, I like how quickly you can throw together a small demo, but for a larger project, I wouldn't recommend using it. ## GPT-3.5 On the other hand, implementing the API turned out to be quite simple. Once the API calls had access to the history of the chatlog, the generated conversations were quite impressive already. There were a couple things that could negatively impact the output, however, such as inconsistent use of first- and second-person pronouns, ambiguous wording, and contradictions within the text itself. What helped generate better output were writing the instructions in a similar tone of voice as the character and including more details about the character itself. One problem that we couldn't get around was jailbreaking the AI through methods such as DAN, since these are specifically designed to circumvent any prompting given to the model, which was the only part we really had any control over. ## Work Distribution Jonas: My job was mostly centered around the technical aspects, such as setting up the API for the LLM in the program, writing code to enable the logic of the core gameplay, and adjusting the visual style for the website. I also tweaked some of the input prompts to include more detail & to generate more consistent output. Lea: Part of my tasks were to write a text with all the information about the suspects. The most important information was: description of the suspect and their job, personality, links and relations to the victim and other suspects, possible motive, alibi, and some events that occurred lately. Another task was to design the characters and help Jonas design the website.