Building a Gigaverse Game Agent
This guide will walk you through creating an AI agent that can play the Gigaverse dungeon crawler game using Daydreams.
This guide will walk you through creating an AI agent that can play the Gigaverse dungeon crawler game using Daydreams.
Prerequisites
Before starting, make sure you have:
- A Gigaverse account
- The following environment variables set up:
ANTHROPIC_API_KEY
: Your Anthropic API keyGIGA_TOKEN
: Your Gigaverse authentication token (Bearer token from browser)
Creating the Agent
First, let's create a basic Gigaverse agent:
How It Works
The Gigaverse agent is built using several key components:
- Context Template: Defines the agent's understanding of the game and its current state:
-
Game Actions: The agent can perform several actions in the game:
attackInDungeon
: Make combat decisions (rock, paper, scissors) or select lootgetPlayerState
: Retrieve the current game statestartNewRun
: Begin a new dungeon run
Understanding Gigaverse Game Mechanics
Gigaverse is a dungeon crawler game with the following key mechanics:
-
Rock-Paper-Scissors Combat: Battles are resolved using the classic rock-paper-scissors game:
- Rock beats Scissors
- Scissors beats Paper
- Paper beats Rock
-
Dungeon Progression: Players advance through the dungeon by defeating enemies.
-
Loot System: After defeating enemies, players can select one of three loot options to enhance their character.
-
Health Management: Players must manage their health throughout the dungeon run.
Core Game Actions
Let's implement the three main actions needed for the Gigaverse agent:
1. Attack in Dungeon
This action handles both combat (rock-paper-scissors) and loot selection:
2. Get Player State
This action retrieves the current state of the player in the dungeon:
3. Start New Run
This action initiates a new dungeon run:
Agent Decision Making
The agent uses the context and player state to make strategic decisions. Here's how the agent approaches the game:
-
Analyzing Enemy Patterns:
- The agent observes patterns in enemy moves over multiple encounters
- It can identify if an enemy favors certain moves (like using "rock" more frequently)
- This information helps the agent make counter-moves (like choosing "paper" against a "rock"-favoring enemy)
-
Loot Selection Strategy:
- After defeating enemies, the agent evaluates the three loot options
- It considers the player's current health, inventory, and progression
- The agent selects loot that complements the player's build or addresses weaknesses
-
Adaptive Gameplay:
- As the dungeon difficulty increases, the agent adjusts its strategy
- It may prioritize health-restoring items when health is low
- The agent can become more conservative or aggressive based on the player's current state
-
Goal-Oriented Planning:
- The agent maintains awareness of its overall goal and current tasks
- It can reprioritize tasks based on the changing game state
- This ensures the agent makes decisions that contribute to long-term success
Integrating with Daydreams
This example showcases several key Daydreams features:
-
Goal-Oriented Context: The agent maintains a structured goal and task list.
-
Action Definitions: Clear, typed actions with Zod schemas for validation.
-
API Integration: Seamless interaction with external APIs (Gigaverse in this case).
-
Error Handling: Robust error handling to manage API failures gracefully.
Next Steps
- Customize the agent's strategy by modifying the context template
- Add more sophisticated decision-making logic
- Implement inventory management and character progression
- Extend the agent to handle more complex game scenarios
For more examples and detailed API documentation, check out our API Reference.
You can find the complete Gigaverse example in the examples directory.