A simple web-based 20 Questions game where an AI thinks of an object and you try to guess it by asking yes/no questions.
- 🤖 Powered by OpenAI's GPT-4o-mini
- 💬 Clean, interactive chat interface built with Shiny for Python
- 🎮 Classic 20 Questions gameplay with reversed roles (AI thinks, you guess)
- 🚀 Simple, lightweight implementation
- Python 3.10+
- OpenAI API key
- Clone this repository:
git clone <your-repo-url>
cd 20-questions-ai-game- Create and activate a virtual environment (recommended):
conda create -n 20questions python=3.10
conda activate 20questions- Install dependencies:
pip install shiny shinychat chatlas python-dotenv- Create a
.envfile in the project root:
OPENAI_API_KEY=your_openai_api_key_hereRun the app:
shiny run app.pyOr specify a custom port:
shiny run --port 3838 app.pyThen open your browser to http://localhost:8000 (or your specified port).
- The AI will think of a common object, animal, person, or place
- You ask yes/no questions to try to guess what it is
- You have up to 20 questions
- If you guess correctly, you win! If not, the AI reveals the answer
- Shiny for Python - Web framework
- shinychat - Chat UI components
- chatlas - LLM integration library
- OpenAI GPT-4o-mini - Language model
MIT License - feel free to use and modify as needed!