Letting AI play my game – building an agentic test harness to help play-testing

Manual play-testing is slow and tedious, but unit tests aren't enough for complex game logic. This article explores how building a text-based test harness allows an AI agent to play, debug, and validate game features autonomously.
I have a solid workflow for making my game with AI. However, every iteration, I have to go through extensive manual play-testing to verify functionality and find bugs. This process is often very slow and tedious. Unit tests are insufficient. I need a way to have the AI validate the actual running system. Today I unlocked an approach to let AI play-test my game along side of me, and it is great.
My game is called Crossword Dungeon. Imagine a crossword forming the layout of an old-school dungeon crawler. Each letter is a "room" and each room has a treasure, trap or monster. Solving a letter of the crossword levels-up the connected rooms, making the dungeon harder. The puzzle solving confounds the RPG elements and the RPG mechanics confound the puzzle solving. It's fun.
This game runs in a browser, so I originally considered a browser automation MCP tool for the AI to use. But games are notoriously hard to test, with lots of state and complex behavior that changes over numerous interactions. The number of screenshots needed just for simple navigation alone would be staggering. Luckily, this game is text heavy and turn based. The AI was able to make a node.js wrapper that didn't modify any of the actual game files, but added a new text based renderer based on the game state, and synthetic events for interaction. This is what it looks like:
=== player @ grid(2,2) Dungeon Level 3 [SPACE] Full map [?] Help ===
; [ ] [A]-[&]-[I]
:: ##### ##### ##### | | |
# ###+ +### # [?]-[?]-[T]-[?]
# A & I # | | | ‖
# ###+ +### # [&]-[?]-[@]=[/]
:~ ## ## ## ## ## ##
# # # # # #
##### ## ## ## ## ## ##
# ### ### ### #
# ? ? T ? # '
# ### ### ### #
## ## ## ## ## ## ## ##
# # # # # # #=#
## ## ## ## ## ## ## ## ~
#+ +### ###+ +###+ +# ~
# & ? @ = / #
#+ +### ###+ +###+ +#
##### ##### ##### #####
--- HERO ---
AdventurerLv.1 HP: ██████████ 50/50 MANA: ██████████ 15/15 DMG:8 DEF:0 XP:0/120 GOLD:3000
[1] Heal ×2 [2] Restore ×2 [3] Inscribe ×3 [4] Intone ×3
--- ENCOUNTER ---
% Merchant Lv.3 Wares and wonder, for the right price.
[1] Health Potion (+20 HP) 16 GOLD
[2] Mana Potion (+10 MANA) 16 GOLD
[3] Inscribe Scroll (reveal letter) 40 GOLD
[4] Intone Scroll (reveal word) 60 GOLD
--- CLUES ---
▲ ▼ MSN competitor
All of the player and encounter panels are shown in text. The actual ASCII dungeon grid is rendered on the left for context of what the player sees. In addition, we added a compact map on the right, representing the same rooms and corridors in a format that was easier for the AI to understand for navigation.
I taught the AI how to use the new playtesting server. This worked fantastically well. The game is fully playable from the terminal across stateless HTTP calls. I start the server, get a snapshot, decide where to go, send a key, read the new state, repeat. The game doesn't know anything different is happening — it's running exactly as it would in the browser, same logic, same event flow, same state machine.
At first I just asked the AI to play the game, kick the tires, and have fun. Then I gave it the ability to design custom fixtures for specific scenarios. Now I could describe a bug I had found and have it recreate a minimal testing fixture to recreate the bug, experience it itself, fix the code, and test again to validate the actual fix! The result? Instead spending hours of manual playtesting, I have an agentic workflow that validates every feature before moving on.
Source: Hacker News















