Matchmaking
Skill Profile
(Select at least one profile to enable specific modules)
Overview
Matchmaking pairs players for multiplayer games based on skill, latency, and party composition. This guide covers ELO, queue systems, and balance algorithms for creating fair, balanced matches that provide good gameplay experiences.
Why This Matters
- Fair Competition: Skill-based matching ensures balanced games and better player experiences
- Player Retention: Good matchmaking reduces frustration and increases engagement
- Social Features: Party/group matching enables friends to play together
Core Concepts & Rules
1. Core Principles
- Follow established patterns and conventions
- Maintain consistency across codebase
- Document decisions and trade-offs
2. Implementation Guidelines
- Start with the simplest viable solution
- Iterate based on feedback and requirements
- Test thoroughly before deployment
Inputs / Outputs / Contracts
- Inputs:
- Player ID, Game Mode, Party ID (optional)
- Player rating, region, preferences
- Entry Conditions:
- Redis server configured for queue management
- Database with players, ratings, matches tables
- Player authentication system implemented
- Outputs:
- Match ID with player assignments
- Team composition
- Match notification via WebSocket
- Artifacts Required (Deliverables):
- Database schema (players, ratings, matches, parties)
- ELO/Glicko rating service
- Matchmaking queue service with Redis
- Team balancer service
- Acceptance Evidence:
- Matchmaking API endpoints functional
- Rating calculation tests passing
- Match quality metrics meeting targets
- Success Criteria:
- Average match wait time < 60 seconds
- Match rating difference < 200 (90th percentile)
- Support 10,000+ concurrent queue players
Skill Composition
- Depends on: Player authentication, Database setup, Redis configuration
- Compatible with: Leaderboards, Real-time Multiplayer, Game Analytics
- Conflicts with: None
- Related Skills: leaderboards, real-time-multiplayer, game-analytics
Quick Start / Implementation Example
- Review requirements and constraints
- Set up development environment
- Implement core functionality following patterns
- Write tests for critical paths
- Run tests and fix issues
- Document any deviations or decisions
# Example implementation following best practices
def example_function():
# Your implementation here
pass
Assumptions / Constraints / Non-goals
- Assumptions:
- Development environment is properly configured
- Required dependencies are available
- Team has basic understanding of domain
- Constraints:
- Must follow existing codebase conventions
- Time and resource limitations
- Compatibility requirements
- Non-goals:
- This skill does not cover edge cases outside scope
- Not a replacement for formal training
Compatibility & Prerequisites
- Supported Versions:
- Python 3.8+
- Node.js 16+
- Modern browsers (Chrome, Firefox, Safari, Edge)
- Required AI Tools:
- Code editor (VS Code recommended)
- Testing framework appropriate for language
- Version control (Git)
- Dependencies:
- Language-specific package manager
- Build tools
- Testing libraries
- Environment Setup:
.env.example keys: API_KEY, DATABASE_URL (no values)
Test Scenario Matrix (QA Strategy)
| Type |
Focus Area |
Required Scenarios / Mocks |
| Unit |
Core Logic |
Must cover primary logic and at least 3 edge/error cases. Target minimum 80% coverage |
| Integration |
DB / API |
All external API calls or database connections must be mocked during unit tests |
| E2E |
User Journey |
Critical user flows to test |
| Performance |
Latency / Load |
Benchmark requirements |
| Security |
Vuln / Auth |
SAST/DAST or dependency audit |
| Frontend |
UX / A11y |
Accessibility checklist (WCAG), Performance Budget (Lighthouse score) |
Technical Guardrails & Security Threat Model
1. Security & Privacy (Threat Model)
- Top Threats: Injection attacks, authentication bypass, data exposure
2. Performance & Resources
3. Architecture & Scalability
4. Observability & Reliability
Agent Directives & Error Recovery
(ข้อกำหนดสำหรับ AI Agent ในการคิดและแก้ปัญหาเมื่อเกิดข้อผิดพลาด)
- Thinking Process: Analyze root cause before fixing. Do not brute-force.
- Fallback Strategy: Stop after 3 failed test attempts. Output root cause and ask for human intervention/clarification.
- Self-Review: Check against Guardrails & Anti-patterns before finalizing.
- Output Constraints: Output ONLY the modified code block. Do not explain unless asked.
Definition of Done (DoD) Checklist
Anti-patterns
Reference Links & Examples
- Internal documentation and examples
- Official documentation and best practices
- Community resources and discussions
Versioning & Changelog
- Version: 1.0.0
- Changelog:
- 2026-02-22: Initial version with complete template structure
Converted and distributed by TomeVault — claim your Tome and manage your conversions.
1---2name: matchmaking3description: Matchmaking pairs players for multiplayer games based on skill, latency, Use when this capability is needed.4---56# Matchmaking78## Skill Profile9*(Select at least one profile to enable specific modules)*10- [ ] **DevOps**11- [x] **Backend**12- [ ] **Frontend**13- [ ] **AI-RAG**14- [ ] **Security Critical**1516## Overview17Matchmaking pairs players for multiplayer games based on skill, latency, and party composition. This guide covers ELO, queue systems, and balance algorithms for creating fair, balanced matches that provide good gameplay experiences.1819## Why This Matters20- **Fair Competition**: Skill-based matching ensures balanced games and better player experiences21- **Player Retention**: Good matchmaking reduces frustration and increases engagement22- **Social Features**: Party/group matching enables friends to play together2324---2526## Core Concepts & Rules2728### 1. Core Principles29- Follow established patterns and conventions30- Maintain consistency across codebase31- Document decisions and trade-offs3233### 2. Implementation Guidelines34- Start with the simplest viable solution35- Iterate based on feedback and requirements36- Test thoroughly before deployment373839## Inputs / Outputs / Contracts40* **Inputs**:41 - Player ID, Game Mode, Party ID (optional)42 - Player rating, region, preferences43* **Entry Conditions**:44 - Redis server configured for queue management45 - Database with players, ratings, matches tables46 - Player authentication system implemented47* **Outputs**:48 - Match ID with player assignments49 - Team composition50 - Match notification via WebSocket51* **Artifacts Required (Deliverables)**:52 - Database schema (players, ratings, matches, parties)53 - ELO/Glicko rating service54 - Matchmaking queue service with Redis55 - Team balancer service56* **Acceptance Evidence**:57 - Matchmaking API endpoints functional58 - Rating calculation tests passing59 - Match quality metrics meeting targets60* **Success Criteria**:61 - Average match wait time < 60 seconds62 - Match rating difference < 200 (90th percentile)63 - Support 10,000+ concurrent queue players6465## Skill Composition66* **Depends on**: Player authentication, Database setup, Redis configuration67* **Compatible with**: Leaderboards, Real-time Multiplayer, Game Analytics68* **Conflicts with**: None69* **Related Skills**: [leaderboards](38-gaming-features/leaderboards/SKILL.md), [real-time-multiplayer](38-gaming-features/real-time-multiplayer/SKILL.md), [game-analytics](38-gaming-features/game-analytics/SKILL.md)7071---7273## Quick Start / Implementation Example74751. Review requirements and constraints762. Set up development environment773. Implement core functionality following patterns784. Write tests for critical paths795. Run tests and fix issues806. Document any deviations or decisions8182```python83# Example implementation following best practices84def example_function():85 # Your implementation here86 pass87```888990## Assumptions / Constraints / Non-goals9192* **Assumptions**:93 - Development environment is properly configured94 - Required dependencies are available95 - Team has basic understanding of domain96* **Constraints**:97 - Must follow existing codebase conventions98 - Time and resource limitations99 - Compatibility requirements100* **Non-goals**:101 - This skill does not cover edge cases outside scope102 - Not a replacement for formal training103104105## Compatibility & Prerequisites106107* **Supported Versions**:108 - Python 3.8+109 - Node.js 16+110 - Modern browsers (Chrome, Firefox, Safari, Edge)111* **Required AI Tools**:112 - Code editor (VS Code recommended)113 - Testing framework appropriate for language114 - Version control (Git)115* **Dependencies**:116 - Language-specific package manager117 - Build tools118 - Testing libraries119* **Environment Setup**:120 - `.env.example` keys: `API_KEY`, `DATABASE_URL` (no values)121122123## Test Scenario Matrix (QA Strategy)124125| Type | Focus Area | Required Scenarios / Mocks |126| :--- | :--- | :--- |127| **Unit** | Core Logic | Must cover primary logic and at least 3 edge/error cases. Target minimum 80% coverage |128| **Integration** | DB / API | All external API calls or database connections must be mocked during unit tests |129| **E2E** | User Journey | Critical user flows to test |130| **Performance** | Latency / Load | Benchmark requirements |131| **Security** | Vuln / Auth | SAST/DAST or dependency audit |132| **Frontend** | UX / A11y | Accessibility checklist (WCAG), Performance Budget (Lighthouse score) |133134135## Technical Guardrails & Security Threat Model136137### 1. Security & Privacy (Threat Model)138* **Top Threats**: Injection attacks, authentication bypass, data exposure139- [ ] **Data Handling**: Sanitize all user inputs to prevent Injection attacks. Never log raw PII140- [ ] **Secrets Management**: No hardcoded API keys. Use Env Vars/Secrets Manager141- [ ] **Authorization**: Validate user permissions before state changes142143### 2. Performance & Resources144- [ ] **Execution Efficiency**: Consider time complexity for algorithms145- [ ] **Memory Management**: Use streams/pagination for large data146- [ ] **Resource Cleanup**: Close DB connections/file handlers in finally blocks147148### 3. Architecture & Scalability149- [ ] **Design Pattern**: Follow SOLID principles, use Dependency Injection150- [ ] **Modularity**: Decouple logic from UI/Frameworks151152### 4. Observability & Reliability153- [ ] **Logging Standards**: Structured JSON, include trace IDs `request_id`154- [ ] **Metrics**: Track `error_rate`, `latency`, `queue_depth`155- [ ] **Error Handling**: Standardized error codes, no bare except156- [ ] **Observability Artifacts**:157 - **Log Fields**: timestamp, level, message, request_id158 - **Metrics**: request_count, error_count, response_time159 - **Dashboards/Alerts**: High Error Rate > 5%160161162## Agent Directives & Error Recovery163*(ข้อกำหนดสำหรับ AI Agent ในการคิดและแก้ปัญหาเมื่อเกิดข้อผิดพลาด)*164165- **Thinking Process**: Analyze root cause before fixing. Do not brute-force.166- **Fallback Strategy**: Stop after 3 failed test attempts. Output root cause and ask for human intervention/clarification.167- **Self-Review**: Check against Guardrails & Anti-patterns before finalizing.168- **Output Constraints**: Output ONLY the modified code block. Do not explain unless asked.169170171## Definition of Done (DoD) Checklist172173- [ ] Tests passed + coverage met174- [ ] Lint/Typecheck passed175- [ ] Logging/Metrics/Trace implemented176- [ ] Security checks passed177- [ ] Documentation/Changelog updated178- [ ] Accessibility/Performance requirements met (if frontend)179180181## Anti-patterns182#183184## Reference Links & Examples185186* Internal documentation and examples187* Official documentation and best practices188* Community resources and discussions189190191## Versioning & Changelog192193* **Version**: 1.0.0194* **Changelog**:195 - 2026-02-22: Initial version with complete template structure196197---198> Converted and distributed by [TomeVault](https://tomevault.io/claim/amnadtaowsoam) — claim your Tome and manage your conversions.199<!-- tomevault:4.0:skill_md:2026-04-13 -->