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.5.tar.gz (44.2 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.5-py3-none-any.whl (29.3 kB view details)

Uploaded Python 3

File details

Details for the file blackrhinorandomminigame-0.1.5.tar.gz.

File metadata

  • Download URL: blackrhinorandomminigame-0.1.5.tar.gz
  • Upload date:
  • Size: 44.2 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.5.tar.gz
Algorithm Hash digest
SHA256 b081e2bed00b0f85e47f844e0bb4c04f736055b127703f4fa750de8862261499
MD5 59c7c2eec445ef64cdc8fd6d7609b1ed
BLAKE2b-256 0006ca2650488e829ebadcd26529d5776db475972a2abadd0f3f91862c176df5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for blackrhinorandomminigame-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 e56af8d359dcb687490b7ac7e0ab562ea5e9a5f0da1fe1b06228d85fcbda453d
MD5 9115a52dca9d83e1d70f83c6729265eb
BLAKE2b-256 769c47c0c3a4fdea3f6454f86869b27395354dbfce244c44dbdaa786a480ed50

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