Inspiration
About 30 years ago, a game called "Battle Pencils" was popular among elementary school children in Japan.
Battle Pencils were hexagonal pencils featuring characters and six different moves, one on each side. Children would gather around their desks during school breaks, take turns rolling their pencils, and battle using the moves that appeared.
The game was simple, but every roll was exciting because the outcome depended on luck.
However, the characters and moves were predefined. Players could not freely create their own characters or customize their abilities.
We wondered what would happen if generative AI could remove these limitations and bring Battle Pencils back to life.
That idea became Re:BATEN.
Our goal was to revive the excitement of this nostalgic Japanese game while allowing players to turn almost anything they imagine into their own Battle Pencil.
What it does
Re:BATEN is a browser-based game that combines traditional Battle Pencils with generative AI and 3D battles.
Players begin by entering any theme, such as "Spicy Ramen" or "Halloween Ninja."
Using Amazon Bedrock, AI generates an original character with HP and six unique moves. Character illustrations can also be generated using Stable Image Core.
Players can then customize their moves through natural-language instructions, such as "Make it stronger." AI updates the moves based on the instruction.
Each pencil can be revised up to three times. Every revision visually shortens the 3D pencil, recreating the experience of sharpening a real pencil.
Once the pencil is ready, players battle a CPU opponent by rolling their 3D pencil. The move on the resulting face is activated, including attacks, healing, boosts, and misses.
Players can also use healing potions, power stones, pencil swaps, or surrender. Battles end when HP reaches zero or the 20-turn limit is reached.
The game supports both Japanese and English, requires no login, and runs in a PC browser.
How we built it
We used Kiro throughout the development process, focusing on three key features: Specs, Steering, and Agent Hooks.
Specs
For feature additions and bug fixes, we created requirements, design documents, and implementation tasks under .kiro/specs/.
The main specs included character-generation, battle-presentation, and ui-localization.
Kiro transformed ideas into requirements, designs, and tasks. We reviewed each stage before proceeding with implementation.
Steering
We created product.md, tech.md, and structure.md to define game rules, Amazon Bedrock integration conventions, project structure, and implementation guidelines.
We established three important principles:
- AI must not control game progression.
- AI output must always be validated and corrected when necessary.
- The game must remain playable even when AI generation fails.
These rules helped Kiro maintain consistent implementations without requiring us to repeat the same instructions.
Agent Hooks
We implemented two hooks that run when an agent turn ends.
The first automatically runs backend or frontend tests after source code changes. If tests fail, Kiro fixes the issues and reruns the tests without deleting, skipping, or weakening them.
The second checks source code changes and automatically updates the design documentation and README to keep them consistent with the implementation.
Technology stack
The frontend uses HTML, CSS, JavaScript, and Three.js for the 3D pencil.
The backend uses Python, FastAPI, Mangum, AWS Lambda, and Amazon API Gateway.
Amazon Bedrock with Claude is used for text generation, while Stable Image Core is used for character illustrations.
Amazon DynamoDB manages game state, and AWS Amplify hosts the application.
We also use GitHub Actions with OIDC for deployment, along with pytest, Hypothesis, Vitest, and fast-check for testing.
Challenges we ran into
1. Handling AI output safely
AI-generated responses sometimes contained unsupported move types, power values outside the allowed range, or additional text surrounding the JSON output.
To handle these cases, we implemented a process that extracts, validates, and corrects the JSON.
Unknown move types are converted to miss, and excessive power values are capped at the allowed maximum.
If generation fails, the system retries once. If it still fails, the game switches to a built-in Battle Pencil so players can continue playing.
Random numbers, damage calculations, and CPU actions are all controlled by server-side game rules rather than generative AI.
2. Image-generation permissions and costs
Stable Image Core is accessed through AWS Marketplace in the us-west-2 region. We initially encountered permission errors when preparing image generation.
Since generating one image costs approximately $0.04, we designed the system to avoid automatic image-generation retries and not generate images for CPU opponents.
Players can also disable automatic character-image generation.
Additionally, we do not store generated images in DynamoDB because of its 400 KB item-size limit.
3. AWS configuration and deployment
Because AWS_REGION is a reserved environment variable in AWS Lambda, we introduced IMAGE_BEDROCK_REGION to configure the image-generation region separately.
We also implemented deployment using GitHub Actions and OIDC.
Accomplishments that we're proud of
Our biggest accomplishment is turning the nostalgic concept of Battle Pencils into a working AI-powered web game.
Players can create a character from their own ideas, generate six original moves, customize those moves using natural language, and use their creations in actual 3D battles.
We are particularly proud of connecting AI-generated creativity with a rule-based battle system.
While generative AI determines the characters and moves, the actual game progression is controlled by server-side rules. This preserves the original game's combination of creativity, strategy, and luck.
We also built safeguards that allow the game to continue even when AI generation fails.
Finally, we established a development workflow using Kiro Specs, Steering, and Agent Hooks to support consistent implementation, automated testing, and documentation maintenance.
What we learned
We learned that reviewing requirements and designs through Kiro Specs before implementation helps identify misunderstandings early and makes AI-assisted development easier to review.
We also learned that defining principles once in Steering is more reliable than repeating the same instructions in every prompt.
Agent Hooks helped automate testing and documentation updates. Explicitly prohibiting the deletion or weakening of tests helped preserve their reliability.
Another important lesson was that generative AI output should not be trusted without validation.
We found that extracting, validating, correcting, and providing fallbacks for AI-generated output is more important than relying only on prompt adjustments.
Finally, image-generation costs, AWS Marketplace permissions, and regional availability should be investigated early because they directly influence system design.
What's next for Re:BATEN
For future development, we would like to explore further improvements to character and move customization, battle presentation, and the overall player experience.
We would also like to continue improving AI-generation reliability and cost efficiency while maintaining the principle that the game must remain playable even when AI services fail.
Our goal is to keep the original excitement of Battle Pencils while exploring new possibilities made possible by generative AI.
Built With
- amazon-api-gateway
- amazon-bedrock
- amazon-dynamodb
- anthropic-claude-haiku
- aws-amplify
- aws-lambda
- boto3
- claude
- css3
- fast-check
- fastapi
- github-actions
- html5
- hypothesis
- iam-oidc
- javascript
- kiro
- mangum
- pytest
- python
- stability-ai
- stable-image-core
- three.js
- vitest



