This project implements a basic game matchmaking system using Flask and Redis. It allows players to join a matchmaking queue and pairs them based on skill levels. The system supports checking a player's status to determine if they have been matched.
- Add players to a matchmaking queue with a skill level.
- Automatically match players based on skill levels.
- Check the matchmaking status of a player.
- Python 3.8+
- Flask
- Redis
- Docker (optional, for running Redis in a container)
-
Clone the repository
git clone https://github.com/siddharthpk/game-matchmaking.git cd game-matchmaking
-
Set up a virtual environment
python -m venv venv source venv/bin/activate # On Windows, use `venv\Scripts\activate`
-
Install dependencies
pip install -r requirements.txt
-
Start Redis
-
Using Docker:
docker run --name redis-matchmaking -p 6379:6379 -d redis
-
Locally:
Ensure Redis is installed and start it according to your system's instructions.
-
-
Start the Flask application
python app.py
This command starts the Flask server and the matchmaking process.
Use curl
commands to test adding players to the matchmaking queue and checking their status.
# Replace <skill_level> with the desired float type skill level of the player
curl -X POST http://localhost:5000/join_queue -H "Content-Type: application/json" -d '{"skill_level": <skill_level>}'
Example:
curl -X POST http://localhost:5000/join_queue -H "Content-Type: application/json" -d '{"skill_level": 10.5}'
# Replace <player_id> with the actual player ID returned by the /join_queue request
curl "http://localhost:5000/check_status?player_id=<player_id>"
Feel free to fork the repository and submit pull requests to contribute to this project. For major changes, please open an issue first to discuss what you would like to change.
Ensure to update tests as appropriate.