Skip to content

shiftlayer-llc/brainplay-simulation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

6 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿค– Codenames Robotics Game

๐Ÿ† Key Innovations

  • ๐ŸŽฒ Dynamic Role Assignment: Players randomly assigned to Red/Blue Spymaster/Operative each game
  • ๐Ÿค– Multi-LLM Tournament: GPT-4 vs Claude Sonnet head-to-head competition
  • ๐ŸŽญ Personality-Driven AI: Risk tolerance, creativity, and confidence affect gameplay
  • ๐Ÿ“Š Real-Time Monitoring: Comprehensive web interface with live game tracking
  • ๐Ÿค ROS2 Distributed: Scalable, robust multi-node architecture
  • ๐Ÿ”ฌ Research Ready: Perfect for AI model comparison and behavioral analysis

๐Ÿ—๏ธ System Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚   ๐ŸŽฎ Frontend   โ”‚    โ”‚  ๐ŸŽญ Players     โ”‚    โ”‚ ๐Ÿค– Isaac Sim   โ”‚
โ”‚                 โ”‚    โ”‚                 โ”‚    โ”‚   (Optional)    โ”‚
โ”‚ โ€ข Game View     โ”‚    โ”‚ โ€ข Alice (GPT-4) โ”‚    โ”‚                 โ”‚
โ”‚ โ€ข Admin Panel   โ”‚    โ”‚ โ€ข Bob (GPT-4)   โ”‚    โ”‚ โ€ข Robot Viz     โ”‚
โ”‚ โ€ข Player Stats  โ”‚    โ”‚ โ€ข Charlie(Claudeโ”‚    โ”‚ โ€ข Speech/TTS    โ”‚
โ”‚                 โ”‚    โ”‚ โ€ข Diana (Claude)โ”‚    โ”‚ โ€ข Animations    โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
          โ”‚                      โ”‚                      โ”‚
          โ”‚              โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”             โ”‚
          โ”‚              โ”‚               โ”‚             โ”‚
          โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ถโ”‚ ๐ŸŽฏ Orchestratorโ”‚โ—€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                         โ”‚               โ”‚
                         โ”‚ โ€ข Role Managerโ”‚
                         โ”‚ โ€ข Game Master โ”‚
                         โ”‚ โ€ข Turn Logic  โ”‚
                         โ”‚ โ€ข Win Detectionโ”‚
                         โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿ”„ Tournament Flow

  1. ๐Ÿš€ Startup: 4 AI players announce readiness
  2. ๐ŸŽฒ Role Assignment: Random team/role distribution each game
  3. ๐ŸŽฎ Gameplay: Turn-based Codenames with LLM-powered decisions
  4. ๐Ÿ“Š Monitoring: Real-time performance tracking and visualization
  5. ๐Ÿ Results: Comprehensive game analysis and player statistics

๐Ÿš€ Quick Start

Prerequisites

  • Linux Os
  • Docker & Docker Compose
  • OpenAI API key
  • Anthropic API key (optional, for Claude players)

1. Clone & Setup

git clone <your-repo-url>
cd codenames_robotics
chmod +x start.sh

2. Configure API Keys

cp .env.template .env
# Edit .env with your API keys
nano .env

3. Start Tournament

# First time (with build)
./start.sh --build

# Subsequent runs
./start.sh

# Include Isaac Sim robots
./start.sh --isaac

4. Access Interfaces


๐ŸŽฎ Game Modes & Configuration

Player Model Configuration

Set different AI models for competitive variety:

# In .env file
PLAYER1_MODEL=gpt-4                    # Alice
PLAYER2_MODEL=gpt-4                    # Bob  
PLAYER3_MODEL=claude-3-5-sonnet-20241022  # Charlie
PLAYER4_MODEL=claude-3-5-sonnet-20241022  # Diana

AI Personality System

Each player has unique behavioral traits:

personality = {
    'risk_tolerance': 0.7,  # 0.0=conservative, 1.0=risky
    'creativity': 0.8,      # 0.0=basic, 1.0=creative  
    'confidence': 0.6       # 0.0=hesitant, 1.0=confident
}

Supported Models

  • OpenAI: gpt-4, gpt-3.5-turbo
  • Anthropic: claude-3-5-sonnet-20241022, claude-3-haiku-20240307

๐Ÿ› ๏ธ Management Commands

# ๐Ÿ“Š Check system status
./start.sh --status

# ๐Ÿ“‹ View real-time logs  
./start.sh --logs

# ๐Ÿงช Run connectivity tests
./start.sh --test

# ๐Ÿ›‘ Stop tournament
./start.sh --stop

# ๐Ÿงน Complete cleanup
./start.sh --clean

# ๐Ÿ”ง Force rebuild
./start.sh --build

๐Ÿ“Š Web Interface Guide

๐ŸŽฎ Game View (/)

  • Live Game Board: 5x5 Codenames grid with real-time updates
  • Team Panels: Red vs Blue with assigned players
  • Turn Tracking: Current team, remaining cards, game state
  • Game Log: History of clues, guesses, and results

โš™๏ธ Admin Panel (/admin)

  • System Metrics: Container health, ROS2 connectivity
  • Player Monitoring: Individual AI status and performance
  • Game Control: Start/stop games, reassign roles
  • Performance Analytics: Success rates, response times

๐Ÿ‘ฅ Player Details (/players)

  • Team Assignments: Current role distribution
  • AI Personalities: Risk tolerance, creativity, confidence
  • Performance Stats: Clues given, guesses made, accuracy
  • Model Information: Which LLM each player is using

๐Ÿค– Isaac Sim Integration

Enable Robot Visualization

# Start with Isaac Sim support
./start.sh --isaac

# Configure in .env
ISAAC_SIM_HOST=localhost
ISAAC_SIM_PORT=8211
ISAAC_ENABLED=true

Robot Features

  • ๐ŸŽค Speech Synthesis: Robots announce clues and guesses
  • ๐Ÿค– Gesture Control: Pointing, thinking, celebration animations
  • ๐ŸŽฌ Scene Management: Dynamic board visualization
  • ๐Ÿ“Š Pose Tracking: Real-time robot position monitoring

๐Ÿ”ง Development Guide

Project Structure

codenames_robotics/
โ”œโ”€โ”€ ๐Ÿณ Docker Files
โ”‚   โ”œโ”€โ”€ Dockerfile.base           # ROS2 + AI dependencies
โ”‚   โ”œโ”€โ”€ Dockerfile.frontend       # Web interface
โ”‚   โ”œโ”€โ”€ docker-compose.yml        # Complete system
โ”‚   โ””โ”€โ”€ entrypoint.sh            # Container initialization
โ”‚
โ”œโ”€โ”€ ๐Ÿค– ROS2 Package: src/codenames_game/
โ”‚   โ”œโ”€โ”€ orchestrator_node.py      # ๐ŸŽฏ Game master & role manager
โ”‚   โ”œโ”€โ”€ player_node.py            # ๐ŸŽญ Universal AI player
โ”‚   โ”œโ”€โ”€ isaac_bridge_node.py      # ๐Ÿค– Robot integration
โ”‚   โ”œโ”€โ”€ game_logic.py             # ๐ŸŽฒ Core Codenames rules
โ”‚   โ”œโ”€โ”€ llm_client.py             # ๐Ÿง  Multi-LLM interface
โ”‚   โ””โ”€โ”€ similarity_model.py       # ๐Ÿ“Š Word relationship analysis
โ”‚
โ”œโ”€โ”€ ๐ŸŒ Frontend/
โ”‚   โ”œโ”€โ”€ web_server.py             # Flask + SocketIO server
โ”‚   โ”œโ”€โ”€ templates/
โ”‚   โ”‚   โ”œโ”€โ”€ index.html            # Game interface
โ”‚   โ”‚   โ”œโ”€โ”€ admin.html            # Admin panel
โ”‚   โ”‚   โ””โ”€โ”€ players.html          # Player monitoring
โ”‚
โ”œโ”€โ”€ ๐Ÿš€ Launch Files/
โ”‚   โ”œโ”€โ”€ 4_player_launch.py        # Full tournament system
โ”‚   โ”œโ”€โ”€ game_launch.py            # Basic game mode
โ”‚   โ””โ”€โ”€ isaac_launch.py           # With robot simulation
โ”‚
โ””โ”€โ”€ โš™๏ธ Configuration/
    โ”œโ”€โ”€ .env.template             # Environment template
    โ”œโ”€โ”€ game_config.yaml          # Game rules & timing
    โ”œโ”€โ”€ llm_config.yaml           # AI model settings
    โ””โ”€โ”€ robot_config.yaml         # Isaac Sim configuration

Adding New AI Models

  1. Update LLM Client (llm_client.py):
def _call_new_provider(self, prompt: str, model: str) -> str:
    # Implement new API integration
    pass
  1. Configure Model (.env):
PLAYER1_MODEL=new-model-name
NEW_PROVIDER_API_KEY=your_key_here

Custom Personality Profiles

Create specialized AI behaviors:

# Conservative player
conservative = {
    'risk_tolerance': 0.2,
    'creativity': 0.4, 
    'confidence': 0.6
}

# Aggressive player  
aggressive = {
    'risk_tolerance': 0.9,
    'creativity': 0.8,
    'confidence': 0.9
}

๐Ÿ“ก API Reference

REST Endpoints

GET  /api/status          # System status
GET  /api/players         # Player information  
POST /api/start_game      # Start new game

WebSocket Events

// Real-time game updates
socket.on('board_update', (data) => { ... });
socket.on('role_assignments', (assignments) => { ... });
socket.on('player_status', (status) => { ... });
socket.on('game_status', (status) => { ... });

ROS2 Topics

# Game coordination
/game/board_state         # Game board updates
/game/role_assignments    # Player role distribution
/game/clue_request        # Spymaster clue requests
/game/clue_response       # Clue responses  
/game/guess_request       # Operative guess requests
/game/guess_response      # Guess responses

# Player management
/game/player_1_status     # Individual player status
/game/player_2_status     # (one topic per player)
/game/player_3_status     
/game/player_4_status     

# Isaac Sim integration
/isaac/robot_commands     # Robot control
/isaac/speech_commands    # Text-to-speech
/isaac/scene_updates      # 3D scene management

๐Ÿ” Troubleshooting

Common Issues

โŒ "API key not found"

# Check .env configuration
cat .env | grep API_KEY
# Restart containers after .env changes
./start.sh --stop && ./start.sh

โŒ "ROS2 nodes not communicating"

# Check ROS2 connectivity
docker-compose exec orchestrator ros2 node list
docker-compose exec orchestrator ros2 topic list | grep game

โŒ "Web interface not loading"

# Check frontend container
docker-compose logs frontend
# Verify port mapping
docker-compose ps

โŒ "Players not joining"

# Check player container logs
docker-compose logs player1
# Verify environment variables
docker-compose exec player1 env | grep PLAYER

Debug Mode

# Enable detailed logging
export LOG_LEVEL=DEBUG
./start.sh --build

# Access container shells
docker-compose exec orchestrator bash
docker-compose exec player1 bash

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •