An AI-powered character guessing game that predicts who you're thinking of by asking intelligent yes/no questions using Bayesian probability and Information Gain algorithms.
- You think of any character (real or fictional)
- The AI asks smart yes/no questions
- It updates probabilities after every answer using Bayesian inference
- It guesses your character with 85โ95% accuracy
- If wrong, it learns from you and improves
React Frontend (port 3000)
โ HTTP/REST
Express Backend (port 5000)
โ
AI Engine
โโโ GameManager โ Session state
โโโ QuestionSelector โ Information Gain algorithm
โโโ ProbabilityEngine โ Bayesian scoring
โโโ GuessGenerator โ Prediction logic
โ
MongoDB Database (port 27017)
โโโ Questions (55)
โโโ Characters (100+)
โโโ GameLogs
- Node.js 16+
- MongoDB (or MongoDB Compass)
git clone https://github.com/Varadha9/Akinator.git
cd Akinatorcd backend
npm installcd ../frontend
npm installcd ../backend
node seed.jsYou should see:
โ
Connected to MongoDB
โ
Inserted 55 questions
โ
Inserted 101 characters
๐ Database seeding completed!
cd backend
node server.jsYou should see:
โ
Connected to MongoDB
๐ Server running on http://localhost:5000
cd frontend
npm startBrowser opens at http://localhost:3000 ๐
Akinator/
โโโ backend/
โ โโโ ai-engine/
โ โ โโโ GameManager.js # Session management
โ โ โโโ QuestionSelector.js # Information gain algorithm
โ โ โโโ ProbabilityEngine.js # Bayesian probability
โ โ โโโ GuessGenerator.js # Character prediction
โ โโโ controllers/
โ โ โโโ gameController.js # API request handlers
โ โโโ models/
โ โ โโโ Character.js # Character schema
โ โ โโโ Question.js # Question schema
โ โ โโโ GameLog.js # Game history schema
โ โโโ routes/
โ โ โโโ gameRoutes.js # API endpoints
โ โโโ services/
โ โ โโโ databaseService.js # DB operations
โ โโโ seed.js # Database seeder
โ โโโ server.js # Express server
โโโ frontend/
โ โโโ src/
โ โโโ components/
โ โ โโโ StartScreen.js # Home screen
โ โ โโโ QuestionScreen.js # Question + answers
โ โ โโโ GuessScreen.js # AI guess display
โ โ โโโ LearningScreen.js # Teach AI new character
โ โโโ pages/
โ โ โโโ Game.js # Main game logic
โ โโโ services/
โ โ โโโ api.js # API client
โ โโโ App.js
โโโ database/
โ โโโ seed-data/
โ โโโ characters.json # 101 characters
โ โโโ questions.json # 55 questions
โโโ docs/
โ โโโ architecture.md
โ โโโ DEPLOYMENT.md
โโโ docker-compose.yml
โโโ README.md
| Method | Endpoint | Description |
|---|---|---|
| GET | /health |
Server health check |
| GET | /api |
API info |
| POST | /api/start-game |
Start new game session |
| POST | /api/answer-question |
Submit answer, get next question |
| POST | /api/submit-feedback |
Tell AI if guess was correct |
| POST | /api/submit-new-character |
Teach AI a new character |
| GET | /api/stats |
Game statistics |
POST /api/start-game
Content-Type: application/json
{ "category": "all" }{
"success": true,
"sessionId": "uuid",
"shouldGuess": false,
"question": {
"id": "...",
"text": "Is your character real?"
},
"progress": 0
}POST /api/answer-question
Content-Type: application/json
{
"sessionId": "uuid",
"questionId": "...",
"answer": "yes"
}{
"success": true,
"shouldGuess": false,
"question": {
"id": "...",
"text": "Is your character from a movie?"
},
"progress": 10
}Valid answers: yes ยท no ยท probably ยท probably_not ยท dont_know
Picks the question that reduces uncertainty the most:
IG(Q) = H(current) - ฮฃ P(answer) ร H(answer)
H = entropy = -ฮฃ p(x) ร logโ(p(x))
Best question = argmax(IG)
Updates character probabilities after each answer:
Score(C) = ฮฃ compatibility(userAnswer, charAnswer)
P(C) = exp(Score(C)) / ฮฃ exp(Score(all))
| Answer | Weight |
|---|---|
| Yes | +1.0 |
| Probably | +0.5 |
| Don't Know | 0.0 |
| Probably Not | -0.5 |
| No | -1.0 |
- Open http://localhost:3000
- Click Start Game (or pick a category)
- Think of any character
- Answer the questions honestly
- The AI will guess your character!
- If wrong โ teach it the correct character
101 characters across 8 categories:
| Category | Examples |
|---|---|
| ๐ฌ Movies | Iron Man, Batman, Harry Potter, Joker |
| ๐ Anime | Naruto, Goku, Luffy, Light Yagami |
| โฝ Sports | Ronaldo, Messi, Virat Kohli, MS Dhoni |
| ๐ป Tech | Elon Musk, Steve Jobs, Bill Gates |
| ๐ฎ๐ณ Indian | Shah Rukh Khan, Amitabh Bachchan |
| ๐ต Music | Michael Jackson, Taylor Swift |
| ๐ Historical | Gandhi, Einstein, Lincoln |
| ๐ฎ Other | Mario, Sonic, Kratos, Link |
Create backend/.env:
PORT=5000
MONGODB_URI=mongodb://localhost:27017/akinator
NODE_ENV=development
MAX_QUESTIONS=20
CONFIDENCE_THRESHOLD=0.8Create frontend/.env:
REACT_APP_API_URL=http://localhost:5000/api# Start all services
docker-compose up --build
# Stop
docker-compose downgit clone https://github.com/Varadha9/Akinator.git
cd Akinator/backend
npm install --production
# Update .env with MongoDB Atlas URI
node server.jscd frontend
# Set REACT_APP_API_URL to your EC2 URL in .env
npx vercel --prod- Create free cluster at https://cloud.mongodb.com
- Get connection string
- Update
MONGODB_URIin.env - Run
node seed.js
| Metric | Value |
|---|---|
| Accuracy | 85โ95% |
| Avg questions to guess | 8โ12 |
| API response time | < 100ms |
| Characters | 101 |
| Questions | 55 |
- LLM integration for dynamic questions
- Voice interaction
- Image-based character hints
- Leaderboard system
- Analytics dashboard
- Mobile app (React Native)
- Multi-language support
- Neural network model
- Fork the repository
- Create a feature branch:
git checkout -b feature/my-feature - Commit changes:
git commit -m 'Add my feature' - Push:
git push origin feature/my-feature - Open a Pull Request
Varadha9
MIT License โ see LICENSE for details.
- Inspired by Akinator.com
- Bayesian inference algorithms
- Information theory principles
Made with โค๏ธ by Varadha9