Cookies

With your permission, we use Google Analytics cookies to measure visits and improve the site. Necessary cookies are always on. You can change your choice or withdraw consent anytime in the footer, under Cookie settings. Cookie Policy

Skip to content

Game Agents ·Advanced

Agent X vs Agent O: Tic-Tac-Toe Game

About this app

An interactive Tic-Tac-Toe game where two AI agents powered by different language models compete against each other built on Agno Agent Framework and Streamlit as UI.

  • Complete open-source code
  • Step-by-step tutorial
  • Runs on your computer

Technical sheet

Category
Game Agents
Difficulty
Advanced
Models
OpenAI, Claude, Gemini, Llama
Frameworks
Agno, AutoGen/AG2, Ollama (local)
Runs locally?
Yes (Ollama)
Required keys
ANTHROPIC_API_KEYGOOGLE_API_KEYGROQ_API_KEYOPENAI_API_KEY

License Apache-2.0 · content curated and maintained by Doutor AI.

Full tutorial

An interactive Tic-Tac-Toe game where two AI agents powered by different language models compete against each other built on Agno Agent Framework and Streamlit as UI.

This example shows how to build an interactive Tic Tac Toe game where AI agents compete against each other. The application showcases how to:

  • Coordinate multiple AI agents in a turn-based game
  • Use different language models for different players
  • Create an interactive web interface with Streamlit
  • Handle game state and move validation
  • Display real-time game progress and move history

Features

  • Multiple AI models support (GPT-4, Claude, Gemini, etc.)
  • Real-time game visualization
  • Move history tracking with board states
  • Interactive player selection
  • Game state management
  • Move validation and coordination

How to Run?

  1. Setup Environment
# Clone the repository
git clone https://github.com/Shubhamsaboo/awesome-llm-apps.git
cd advanced_ai_agents/autonomous_game_playing_agent_apps/ai_tic_tac_toe_agent

# Install dependencies
pip install -r requirements.txt

2. Install dependencies

pip install -r requirements.txt

3. Setup API Keys

The game supports multiple AI models. Create a .env file in this directory and add your API keys:

  1. Create a .env file:
# In the ai_tic_tac_toe_agent directory
touch .env
  1. Add your API keys to the .env file:
# Required for OpenAI models (gpt-4o, o3-mini)
OPENAI_API_KEY=your_actual_openai_api_key_here

# Optional - for additional models
ANTHROPIC_API_KEY=your_actual_anthropic_api_key_here  # For Claude models
GOOGLE_API_KEY=your_actual_google_api_key_here        # For Gemini models
GROQ_API_KEY=your_actual_groq_api_key_here           # For Groq models

> Note: Replace the placeholder values with your actual API keys. The app will show helpful error messages if required keys are missing.

4. Run the Game

streamlit run app.py

How It Works

The game consists of three agents:

  1. Master Agent (Referee)
  • Coordinates the game
  • Validates moves
  • Maintains game state
  • Determines game outcome
  1. Two Player Agents
  • Make strategic moves
  • Analyze board state
  • Follow game rules
  • Respond to opponent moves

Available Models

The game supports various AI models:

  • GPT-4o (OpenAI)
  • GPT-o3-mini (OpenAI)
  • Gemini (Google)
  • Llama 3 (Groq)
  • Claude (Anthropic)

Game Features

  1. Interactive Board
  • Real-time updates
  • Visual move tracking
  • Clear game status display
  1. Move History
  • Detailed move tracking
  • Board state visualization
  • Player action timeline
  1. Game Controls
  • Start/Pause game
  • Reset board
  • Select AI models
  • View game history
  1. Performance Analysis
  • Move timing
  • Strategy tracking
  • Game statistics

From the same category

Game AgentsAdvanced

AI 3D PyGame Visualizer with DeepSeek R1

This Project demonstrates R1's code capabilities with a PyGame code generator and visualizer with browser use. The system uses DeepSeek for reasoning,…

  • OpenAI
  • DeepSeek
Game AgentsAdvanced

Agent White vs Agent Black: Chess Game

An advanced Chess game system where two AI agents play chess against each other using Autogen in a streamlit app. It is built with robust move validat…

  • OpenAI

Need a tailor-made solution?

Not sure where to start with AI in your business? Get a free assessment and a tailored plan - no commitment.

Save hours every week with AI, no hassle

Doutor AI gives you 1,859 ready-to-copy AI prompts, by industry and in plain English - plus a complete technical library for those who want to go further.

See plans