Two powerful approaches to AI agents for Minecraft:
Chat with an AI that plays Minecraft for you!
A conversational assistant that:
- ๐ฌ Chats in natural language: "Go mine that tree" or "Build a house here"
- ๐ฎ Controls real Minecraft: Direct keyboard/mouse automation
- ๐ค Executes complex tasks: Understands multi-step instructions
- ๐ง Learns from conversation: Remembers context and preferences
Perfect for: Playing Minecraft with an AI companion, automating repetitive tasks, learning Minecraft mechanics
# Install dependencies for chat agent
pip install loguru mss pyautogui pynput openai
# Check installation
python minecraft_chat.py --check-deps
# Start the conversational agent
python minecraft_chat.py# With OpenAI API key (recommended)
export OPENAI_API_KEY="your-api-key"
python minecraft_chat.py
# Basic mode (no API key needed)
python minecraft_chat.py๐ค You: Go forward and mine some wood
๐ค Agent: I'll help you mine those trees! Moving forward and breaking the wood blocks.
๐ค You: Now build a small house with that wood
๐ค Agent: Perfect! I'll use the wood we collected to build a cozy house. Starting with a 5x5 foundation...
- Movement: "go forward", "turn left", "walk backward"
- Mining: "break this block", "mine that tree", "dig down"
- Building: "place a block", "build a wall", "make a platform"
- Complex: "build a house", "find diamonds", "make a farm"
Self-improving agent for AI research
A modular research framework inspired by Google's SIMA 2:
- Task Setter: Proposes tasks with estimated rewards
- Agent: Executes tasks in game environments
- Reward Model: Evaluates episode performance
- Self-Generated Experience: Stores and manages episode data
- Self-Improvement Loop: Orchestrates the learning cycle
Perfect for: AI research, reinforcement learning experiments, academic studies
# Install dependencies
pip install loguru mss pyautogui pynput openai
# Start chatting with your Minecraft assistant
python minecraft_chat.py
# Example conversation:
# You: "go forward and mine some wood"
# Agent: "I'll move forward and break those wood blocks for you!"# Basic installation
pip install -e .
# Train the research agent
python -m src.main --mode train --env dummy --generations 5
# Train with Minecraft (requires MineRL)
pip install minerl
python -m src.main --mode train --env minecraft --generations 3- Conversational Agent Setup - Complete guide for the chat-based Minecraft assistant
- Research Agent Setup - Detailed setup for AI research applications
โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ
โ Task Setter โโโโโโ Agent โโโโโโ Game Env โ
โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ
โ โ
โ โโโโโโโโผโโโโโโโ
โ โ Episodes โ
โ โโโโโโโโฌโโโโโโโ
โ โ
โผ โโโโโโโโผโโโโโโโ
โโโโโโโโโโโโโโโ โ Self-Gen. โ โโโโโโโโโโโโโโโ
โReward Model โโโโโโโ Experience โโโโโโบโ Storage โ
โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ
โ โโโ config/ โ โ โโโ config.py # Configuration classes โ โโโ env/ โ โ โโโ base_env.py # Abstract game environment โ โ โโโ dummy_env.py # Simple test environment โ โ โโโ minecraft_env.py # Minecraft environment wrapper โญ โ โ โโโ io_controller.py # Game I/O interfaces โ โ โโโ vision.py # Observation encoding โ โโโ agent/ โ โ โโโ policy.py # Policy implementations โ โ โโโ agent.py # Main agent orchestrator โ โโโ tasks/ โ โ โโโ task_schema.py # Task data structures โ โ โโโ task_setter.py # Task generation logic โญ โ โโโ reward/ โ โ โโโ reward_model.py # Episode scoring โญ โ โโโ experience/ โ โ โโโ types.py # Core data types โ โ โโโ buffer.py # In-memory experience store โ โ โโโ storage.py # Persistent experience store โ โโโ training/ โ โ โโโ self_improvement_loop.py # Main training loop โ โโโ utils/ โ โโโ logging_utils.py # Structured logging โ โโโ seed.py # Random seed management โโโ tests/ โโโ test_experience.py # Experience system tests โโโ test_agent_interfaces.py # Agent integration tests
## Key Components
### Environment Interface
The `GameEnv` abstract base class provides a clean interface for any video game. Includes:
- `DummyGameEnv` for testing and development
- `MinecraftEnv` for Minecraft gameplay via MineRL or raw control
### Minecraft Support
The system now supports Minecraft through two modes:
- **MineRL**: Uses the MineRL research platform for structured Minecraft gameplay
- **Raw Control**: Direct keyboard/mouse control of Minecraft client (experimental)
Minecraft-specific features:
- Specialized action space for movement, building, mining, crafting
- Minecraft vision encoder for processing pixel observations
- Task templates for common Minecraft objectives (collect wood, build structures, etc.)
- Reward model understanding Minecraft progress indicators
### Experience System
Episodes are stored both in-memory (`ReplayBuffer`) and persistently (`storage.py`) as the "Self-Generated Experience" that drives learning.
### Task Generation
The `TaskSetter` proposes new tasks based on previous performance, with hooks for LLM-based task generation.
### Reward Learning
The `RewardModel` scores episodes, with clear interfaces for plugging in learned reward functions or LLM-based evaluation. Now includes Minecraft-specific scoring based on inventory changes, health preservation, and exploration.
## Minecraft Configuration
The Minecraft environment can be configured via CLI arguments or config files:
```python
# Example configuration
minecraft_config = MinecraftConfig(
backend="minerl", # "minerl" or "raw"
environment_name="MineRLNavigateDense-v0", # MineRL environment
max_steps=1000,
frame_skip=1,
render=True,
action_space="discrete" # "discrete" or "continuous"
)
Supported MineRL environments include:
MineRLNavigateDense-v0: Navigation with dense rewardsMineRLTreechop-v0: Tree chopping tasksMineRLObtainDiamond-v0: Complex diamond obtaining task
For direct Minecraft control:
- Start Minecraft client
- Use
--env minecraft --minecraft-backend raw - Ensure Minecraft window is focused and accessible
Note: Raw control mode is experimental and requires additional setup.
pytest tests/black src/ tests/
ruff src/ tests/
mypy src/- RL Algorithms: Implement proper policy gradient/Q-learning in
policy.py - Scalability: Add distributed training and experience storage
- Vision Models: Plug in CNN/transformer backbones in
vision.py
- More Games: Add support for other games beyond Minecraft
- Real Input Control: Complete the raw Minecraft controller implementation
- MineRL Integration: Test and optimize MineRL environment performance
- Reward Learning: Train neural reward models or integrate LLM evaluation
- Task Generation: Add LLM-based creative task generation
- Hierarchical Tasks: Implement task decomposition and sub-goals
- Advanced Actions: Implement crafting, building, combat mechanics
- State Detection: Add inventory tracking, health monitoring, environment analysis
- Long-Term Goals: Add support for complex, multi-step Minecraft objectives
MIT License - see LICENSE file for details.