feat: updated tictactoe agent README

This commit is contained in:
ShubhamSaboo 2025-01-01 19:19:31 -06:00
parent 8feb6b0c5d
commit bae1526a4a
2 changed files with 27 additions and 39 deletions

View file

@ -1,30 +1,32 @@
# AI vs AI Tic-Tac-Toe Game 🎮
# 🎮 Agent X vs Agent O: Tic-Tac-Toe Game
An interactive Tic-Tac-Toe game where two AI agents powered by different language models compete against each other built on phidata Agent Framework and Streamlit as UI. Watch as GPT-4O battles against either DeepSeek V3 or Google's Gemini 1.5 Flash in this classic game!
An interactive Tic-Tac-Toe game where two AI agents powered by different language models compete against each other built on phidata Agent Framework and Streamlit as UI. Watch as GPT-4O battles against either DeepSeek V3 or Google's Gemini 1.5 Flash in this classic game.
## Demo
## Features
### Multi-Agent System
- Player X: OpenAI's Gemini Flash 2.0
- Player O: DeepSeek v3
- Judge: GPT-4o for game outcome validation
https://github.com/user-attachments/assets/071597e8-0f06-4cb0-bd19-dccf229b7317
### Interactive Interface
- Real-time game board visualization
- Move-by-move analysis
- Agent response tracking
- Clear game status updates
### Strategic Gameplay
- AI-powered move decisions
- Winning strategy implementation
- Opponent move blocking
- Victory condition monitoring
## Features 🌟
- Player X: Powered by OpenAI's GPT-4o (o1 models as api is yet to roll out for tier)
- Player O: Choice between DeepSeek AI or Google's Gemini
- Interactive game board using Streamlit
- Real-time move visualization
- AI Judge to determine game outcomes
- Clean and intuitive user interface
## Prerequisites 📋
## Prerequisites
- Python 3.8+
- OpenAI API key
- Either DeepSeek API key or Google API key (for Player O)
## How to Run 🚀
## How to Run
1. **Setup Environment**
```bash
@ -52,16 +54,16 @@ https://github.com/user-attachments/assets/071597e8-0f06-4cb0-bd19-dccf229b7317
- Watch as the AI agents battle it out!
- Monitor the game progress and final results
## Game Components 🎯
## Game Components
- **Game Board**
- 3x3 interactive grid
- Real-time move visualization
- Clear symbol placement (X/O)
- **AI Players**
- Player X (GPT-4o): Strategic offensive moves
- Player O (DeepSeek/Gemini): Defensive countermoves since this agent started later
- **AI Agent Players**
- Player X: Strategic offensive moves
- Player O: Defensive countermoves since this agent started later
- AI Judge: Game outcome validation
- **Game Flow**

View file

@ -6,7 +6,7 @@ from phi.model.deepseek import DeepSeekChat
from phi.model.google import Gemini
# Streamlit App Title
st.title("🤖 Tic-Tac-Toe: AI vs AI")
st.title("🎮 Agent X vs Agent O: Tic-Tac-Toe Game")
# Enhanced Welcome Message
with st.chat_message("assistant"):
@ -16,8 +16,8 @@ with st.chat_message("assistant"):
Here's what you need to know:
""")
st.info("""
- **Player X**: Powered by OpenAI's GPT-4.
- **Player O**: Powered by DeepSeek's AI or Google's Gemini (if DeepSeek API key is not provided).
- **Player X**: Powered by Google's Gemini Flash 2.0.
- **Player O**: Powered by DeepSeek v3.
- **How to Play**: Enter your API keys in the sidebar, click **Start Game**, and watch the AI battle it out!
- **Goal**: The first player to get three of their symbols in a row (horizontally, vertically, or diagonally) wins.
- **Draw**: If the board fills up without a winner, the game ends in a draw.
@ -106,7 +106,7 @@ if google_api_key:
if 'openai_api_key' in st.session_state:
player_x = Agent(
name="Player X",
model=OpenAIChat(id="gpt-4o", temperature=0.1, api_key=st.session_state.openai_api_key),
model=Gemini(id="gemini-2.0-flash-exp", api_key=st.session_state.google_api_key),
instructions=[
"You are a Tic-Tac-Toe player using the symbol 'X'.",
"Your opponent is using the symbol 'O'. Block their potential winning moves.",
@ -133,20 +133,6 @@ if 'openai_api_key' in st.session_state:
],
markdown=True,
)
elif 'google_api_key' in st.session_state:
player_o = Agent(
name="Player O",
model=Gemini(id="gemini-1.5-flash", api_key=st.session_state.google_api_key),
instructions=[
"You are a Tic-Tac-Toe player using the symbol 'O'.",
"Your opponent is using the symbol 'X'. Block their potential winning moves.",
"Make your move in the format 'row, col' based on the current board state.",
"Strategize to win by placing your symbol in a way that blocks your opponent from forming a straight line.",
"Do not include any explanations or extra text. Only provide the move.",
"Row and column indices start from 0.",
],
markdown=True,
)
else:
st.warning("Please provide either a DeepSeek API key or a Google API key for Player O.")