I needed a project for Anthropic's AI Fluency Course to crystalise the learnings of the 4D framework and had an idea I'd been sitting on for a while: build a game, then build an AI bot that plays it. Not for fun (although it is), but as a functional testing tool. The bot would validate the entire application stack on every deployment; UI, API, database; by actually playing the game and submitting scores.

The game

The game itself is a classic Tetris built on top of classic-tetris-js with a blue-to-pink gradient theme, glassmorphism UI, and a global leaderboard. The interesting part is the architecture: it's fully serverless on AWS.

Browser HTML5 Canvas + JS CloudFront + S3 Static hosting + CDN API Gateway Score submit + leaderboard Lambda Node.js 20.x functions DynamoDB Scores + leaderboard Route 53 DNS + custom domain

The front-end is vanilla JavaScript with an HTML5 Canvas. CloudFront serves the static files from S3. When a player finishes a game, their score is submitted via API Gateway to a Lambda function that writes it to DynamoDB. A second Lambda function retrieves the top 10 scores for the leaderboard. The whole stack costs a few £ a month.

The entire application; game code, Lambda functions, CloudFormation templates, and the GitHub Actions CI/CD pipeline; was built collaboratively with Claude Code (4D approach). Infrastructure deploys automatically on push to main using OIDC authentication with AWS; the same IaC patterns from the Ghost project but applied to a simpler stack.

The AI bot

The main outcome of the project was the bot. I used Claude Code to build a Playwright-based AI that launches a browser, navigates to the live game, and plays Tetris autonomously. It uses piece placement algorithms with lookahead planning to decide where to drop each piece, then submits the final score through the same API the human players use.

The bot validates the complete user journey: can the game load? Can pieces be placed? Does the score submit correctly? Does the leaderboard update? If any of those steps fail, the deployment is broken. It's functional testing by actually using the application, not by mocking it.

Running the bot locally is a single command:

npm install playwright
node tetris-ai.js https://tetris.yourdomain.com

In the CI/CD pipeline, the bot runs as the final step after all infrastructure is deployed. If the bot can play a complete game and submit a score, the deployment is validated. If it can't, something is wrong.

What this proved

Two things:

Firstly. Co-engineering with Claude leveraging the 4D framework works extremely effectively.

Secondly. The enterprise use case I was exploring is whether AI bots can complete functional testing. For this application, the answer is yes. The bot exercises the full stack; front-end rendering, user interaction, API calls, database writes, and data retrieval; in a way that unit tests and integration tests individually can't.

It's not a replacement for all testing. You still need unit tests for business logic and security testing for APIs. But for end-to-end validation of "does the application actually work from a user's perspective", having a bot that literally plays the game is surprisingly effective.

Where it is now

The original AWS version served its purpose as a learning project, but the live version today has moved to Vercel with Clerk for OAuth authentication and Neon PostgreSQL replacing DynamoDB for the leaderboard. The security improvements were deliberate; the AWS version had a CORS vulnerability in the leaderboard API that made for a good Wiz demo, and the rebuild addressed that properly.

The game is live at tetris.jamescarty.co.uk and the original source code including the bot is on GitHub.