← Back to homepage

🎮 AI Game Service Platform

Integration project – AI-driven Game Services

A fully AI-driven Game Service Platform built in Python. The platform lets game developers integrate intelligent NPCs into their applications through a REST API.

Demo Video (dry-run)

📌 Project overview

The system consists of:

🎲 Implemented Games

1️⃣ Tic-Tac-Toe

Implementation

  • Complete game logic (legal moves, win/draw detection)
  • NPC with a perfect strategy
  • REST integration via /api/v1/move

Algorithm: Minimax

Because Tic-Tac-Toe has a small search space, the AI can fully calculate every possible game. As a result, it plays perfectly and cannot lose.

2️⃣ Checkers

Implementation

  • Complete game rules
  • Legal move detection
  • Evaluation function for board positions
  • Adjustable difficulty through search depth

Algorithm: Depth-limited Minimax

The board is too large to search exhaustively. So we limit the search depth (e.g. depth = 8) and use an evaluation function to score intermediate positions.

3️⃣ Reversi

Implementation

  • Legal move validation
  • Disc flipping logic
  • Game state evaluation
  • Simulation-based AI

Algorithm: Monte Carlo Tree Search (MCTS)

Reversi has a high branching factor (10 possible moves per turn on average). Minimax would become exponentially too slow.

That's why we use MCTS with four phases:

  1. Selection
  2. Expansion
  3. Simulation
  4. Backpropagation

We run ±3000 simulations and pick the move with the highest win rate. The more time the algorithm gets, the stronger the AI plays.

4️⃣ Blackjack

Implementation

  • Card system
  • Score counting
  • Bust detection
  • Decision logic (Hit/Stand)

Algorithm: Expectimax

Blackjack contains an element of chance (random cards). That's why we use Expectimax instead of Minimax.

Expectimax:

  • MAX nodes → player
  • CHANCE nodes → probability distributions
  • Calculation of the expected value

The AI picks the action with the highest expected value.

🧠 Overview of the AI algorithms

🔹 Minimax

Used for: TicTacToe, Checkers

Properties:

  • Recursive tree search
  • Maximising vs minimising player
  • Optional depth limit
  • Evaluation function for complex games

🔹 Monte Carlo Tree Search (MCTS)

Used for: Reversi

Properties:

  • Sampling-based simulations
  • No full tree needed
  • Time-dependent (more time = better move)
  • Ideal for a high branching factor

🔹 Expectimax

Used for: Blackjack

Properties:

  • Extension of Minimax
  • Supports chance nodes
  • Decisions based on expected value
  • Suited to stochastic games

🏗️ Architecture

We use a 4-layer architecture:

1️⃣ API Layer

  • FastAPI endpoints
  • Rate limiting
  • Pydantic validation
  • Asynchronous processing

2️⃣ Service Layer

  • GameMoveService
  • MinimaxService
  • MCTSService
  • ExpectimaxService

3️⃣ Core Layer

  • GameLogicFactory
  • AlgorithmFactory
  • GameInterfaces
  • Concrete game logic classes

4️⃣ Data Layer

  • PostgreSQL
  • pgvector
  • Player analytics storage

This separation provides maintainability, scalability, testability and clear responsibilities.

🤖 RAG Chatbot System

Alongside the game AI, we built our own Retrieval-Augmented Generation system.

1️⃣ Upload & Preprocessing

  • pypdf (PDF extraction)
  • RecursiveCharacterTextSplitter (LangChain)
  • 1000 character chunks
  • 200 overlap

2️⃣ Embeddings

  • sentence-transformers
  • model: all-MiniLM-L6-v2
  • 384-dimensional vectors
  • Local model (no external API calls)

3️⃣ Vector Search

  • PostgreSQL + pgvector
  • HNSW index
  • Cosine similarity
  • Filtering on game_type

4️⃣ Generation

  • Gemini 2.5 Flash Lite
  • Prompt engineering
  • Fallback mechanism
  • Confidence score

📊 Recommendation System

The system tracks:

  • Which player plays which game
  • Win/loss ratio
  • Difficulty level
  • Engagement

Types of recommendations:

  • Progression based
  • Difficulty scaling
  • Content-based filtering
  • Collaborative filtering
  • Re-engagement strategies

🔐 Security

🚀 Conclusion

In this project we:

This project combines:

Game developmentArtificial IntelligenceBackend architectureMachine learningData engineeringAPI design

The result is a fully AI-driven game service platform.