Engineer builds Slay the Spire-playing AI in just 3 hours - and how he built it
Amazon employee Banjo Obayomi built an AI capable of playing the roguelike deck-building game Slay the Spire in just three hours, and posted a post explaining how he did it.
Community | I Built an LLM Bot in 3 hours to Conquer Slay the Spire
Slay the Spire is a game with over 200 cards and over 50 enemies and events, and is highly popular because the situation changes every time you play, making it highly replayable. Obayomi is also a fan of Slay the Spire, having played it for over 160 hours, and decided to create an AI that can play Slay the Spire while waiting for the sequel, which is scheduled to appear in 2025.
When Obayomi researched the AI that plays Slay the Spire, he discovered a skeleton project created five years ago. After building an environment based on the skeleton project and confirming that it worked without any problems, Obayomi used Amazon Q to ask for an explanation of the code, asking, 'What does this code do?' Amazon Q's response told him where to incorporate the large-scale language model (LLM), which is the content of the AI, into the code, and he was able to start working smoothly.
Slay the Spire is roughly divided into a 'room selection' phase and a 'combat' phase, but Obayomi decided to focus on the combat phase first, passing game state data to the LLM to determine the next action to take. Since the class that stores game information did not implement a function to output the state as a string, he had Amazon Q generate code to extract the relevant game state information.
Although Amazon Q is good at understanding and generating code, Obayomi said that the system prompt design did not satisfy him. 'For tasks other than understanding, debugging, and generating code, it may be better to use a different LLM product,' Obayomi said.
Obayomi decided to use Amazon Bedrock's Claude Haiku as the LLM. When he ran the code, the AI generated valid actions and started playing the game autonomously, but after a while it crashed.
Obayomi looked into the function that performed the action and found a bug that could cause the card to select an invalid target. When he asked Amazon Q to resolve the error, it generated code to output an exception, and Obayomi wrote code to handle the situation appropriately.
In this way, Obayomi succeeded in getting Claude Haiku to play Slay the Spire within three hours of starting the project. Although there was a source code, Amazon Q allowed him to quickly understand, update and debug other people's code written five years ago.
Claude Haiku said he was able to reach the second of the three bosses. Since defeating a boss requires long-term planning, such as card selection and combo selection, Obayomi said that he will improve the prompts to allow players to use Claude Opus to carry out general strategies in the future.
Related Posts:
in Software, Posted by log1d_ts