Skip to main content

A lighthearted Python package with random mini-game utilities.

Project description

blackrhinorandomminigame Python Package

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

  1. Install this package using pip:
pip install blackrhinorandomminigame
  1. 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:

  1. Clone the Repository:
git clone https://github.com/swe-students-spring2026/3-package-black_rhino.git
cd 3-package-black_rhino
  1. Set Up Virtual Environment (pipenv):
pip install pipenv
pipenv shell
pipenv install
  1. Run Tests:
pytest
  1. Build Package:
python -m build
  1. 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

blackrhinorandomminigame-0.1.6.tar.gz (44.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

blackrhinorandomminigame-0.1.6-py3-none-any.whl (29.4 kB view details)

Uploaded Python 3

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

Hashes for blackrhinorandomminigame-0.1.6.tar.gz
Algorithm Hash digest
SHA256 bad7062aeb5257ca6ccc3534db380f56b56420726780d257fb325026436c1205
MD5 ac7a949c71eced0a9065f8fc7f9a2529
BLAKE2b-256 3a785801e474913a241ac13df3cbb8b88ee3ab7e63fa6cbf7e04fea3c1abcc71

See more details on using hashes here.

File details

Details for the file blackrhinorandomminigame-0.1.6-py3-none-any.whl.

File metadata

File hashes

Hashes for blackrhinorandomminigame-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 19e546eae8d67e8b38d927d9dc87ca9b7c627a055e3c542afbd0352903ff645d
MD5 0912d89b97e8011fb8483e941a853dc3
BLAKE2b-256 097ea6de1fcaf88914fd05291aaac70a883b8244d432022f1baeebb7b68fe0fa

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page