This FastAPI project calculates and delivers the probabilities of Bob winning a turn-based dice game against Alice. The competition involves alternately rolling a fair k-sided die, where the first player to roll a value equal to k wins. The API is designed to assess these probabilities for k
-sided dice, ranging from 6
to 99
.
The API is versatile, allowing users to specify the k
parameter through an optional header K
. When this header is included, the endpoint responds with the probability for the specified k
. If the header is omitted, the endpoint defaults to returning a comprehensive list of probabilities for the entire range of 6
to 99
.
- Brew
- Python 3.10
- Go-Task
Please visit official Homebrew site for detailed guide to install Brew.
Use Brew to install the specific version of Python required for this project:
brew install python@3.10
Go-Task is used for task automation within the project. Install it using Brew:
brew install go-task
Follow these steps to set up your development environment:
This command installs all necessary dependencies for both development and the project itself:
task install-dependencies
Ensure code quality and consistency by running the linter:
task lint
Execute the project's test suite to verify everything is functioning correctly:
task test
To start the FastAPI server and interact with the API locally:
task run
This command launches the FastAPI application, making it accessible via http://localhost:8000. You can explore the API routes using FastAPI's interactive API documentation at http://localhost:8000/docs.