A lighthearted Python package with random mini-game utilities.
Project description
blackrhinorandomminigame Python Package
Description
A Python package to simplify game-related functions, so that developers don't have to hard-code probability and score-related code. This package includes:
- Choose Option: Randomly chooses an element of a list.
- Roll Dice: Roll a certain number of dice with custom face values.
- Coin Flip: Flips a heads or tails coin a custom number of times, returning heads, tails, or tie.
- Generate Scores: Randomly assigns scores to elements of a list.
- Generate Teams: Evenly breaks down a list into a custom number of teams.
PyPi Package
This package on PyPi: Random Minigame
How to Install and Use This Package
Requirements
This package requires Python 3.12 or later.
Installation
- Install this package using pip:
pip install blackrhinorandomminigame
- Import this package into your Python file:
from blackrhinorandomminigame import random_minigame as rm
Usage examples
Here is how to use each function in your own code:
- Choose Option:
options = ["rock", "paper", "scissors"]
choice = rm.choose_option(options)
print(f"Opponent chose: {choice}")
- Roll Dice:
total = rm.roll_dice(num_rolls=2, num_sides=6, low_val=1, step=1)
print(f"Total of dice roll: {total}")
- Coin Flip:
result = rm.coin_flip(num_flips=5)
print(f"Coin flip outcome: {result}")
- Generate Scores:
players = ["Alice", "Bob", "Charlie", "Diana"]
scores = rm.generate_scores(names=players, low_score=0, high_score=100, ties_allowed=True)
print(f"Scores: {scores}")
- Generate Teams:
players = ["Alice", "Bob", "Charlie", "Diana", "Eve", "Frank"]
teams = rm.generate_teams(names=players, num_teams=2)
print(f"Teams: {teams}")
Function Documentation
| Function | Parameters | Description | Returns |
|---|---|---|---|
choose_option |
choices (list) |
Randomly selects an element from a list. Raises TypeError if not a list, ValueError if empty. | Selected element |
roll_dice |
num_rolls (int), num_sides (int), low_val (int), step (int) |
Rolls dice where faces are generated as: low_val, low_val+step, low_val+2*step, etc. | Total sum of all dice rolls |
coin_flip |
num_flips (int) |
Flips a coin the specified number of times. | "heads", "tails", or "tie" |
generate_scores |
names (list), low_score (int), high_score (int), ties_allowed (bool) |
Assigns random scores to each name. If ties_allowed is False, ensures all scores are unique. | Dictionary mapping names to scores |
generate_teams |
names (list), num_teams (int) |
Randomly distributes names into the specified number of teams. | Dictionary mapping team numbers to lists of members |
Complete Example Program
Here is a full Python program demonstrating all functions together: Example Program
How to Contribute to This Project
Follow these steps to set up the project locally:
- Clone the Repository:
git clone https://github.com/swe-students-spring2026/3-package-black_rhino.git
cd 3-package-black_rhino
- Set Up Virtual Environment (pipenv):
pip install pipenv
pipenv shell
pipenv install
- Run Tests:
pytest
- Build Package:
python -m build
- Exit the Virtual Environment:
exit
Teammates
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file blackrhinorandomminigame-0.1.6.tar.gz.
File metadata
- Download URL: blackrhinorandomminigame-0.1.6.tar.gz
- Upload date:
- Size: 44.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bad7062aeb5257ca6ccc3534db380f56b56420726780d257fb325026436c1205
|
|
| MD5 |
ac7a949c71eced0a9065f8fc7f9a2529
|
|
| BLAKE2b-256 |
3a785801e474913a241ac13df3cbb8b88ee3ab7e63fa6cbf7e04fea3c1abcc71
|
File details
Details for the file blackrhinorandomminigame-0.1.6-py3-none-any.whl.
File metadata
- Download URL: blackrhinorandomminigame-0.1.6-py3-none-any.whl
- Upload date:
- Size: 29.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
19e546eae8d67e8b38d927d9dc87ca9b7c627a055e3c542afbd0352903ff645d
|
|
| MD5 |
0912d89b97e8011fb8483e941a853dc3
|
|
| BLAKE2b-256 |
097ea6de1fcaf88914fd05291aaac70a883b8244d432022f1baeebb7b68fe0fa
|