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. If names cannot be distributed evenly, number of members in each team will only differ by a maximum of 1. 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.7.tar.gz (44.7 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.7-py3-none-any.whl (29.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: blackrhinorandomminigame-0.1.7.tar.gz
  • Upload date:
  • Size: 44.7 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.7.tar.gz
Algorithm Hash digest
SHA256 beff640afbf9528640504b1e832eeba35263bb527f89d437df35c37c356ffc7a
MD5 3737b564540ca7f0ebb5fd51184bdcf8
BLAKE2b-256 c6d783a220c9876ba3790d0a19c3ae56a8fb1e5f15f62a56e97361abe404c3f5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for blackrhinorandomminigame-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 a1393abebc6da7be474270a97dce9b02d8dbe347f41e3837a87f89054643de36
MD5 91ff9d9da4306174826f2d4eb0f7b843
BLAKE2b-256 a23af032a9cf0a029392af6db4a22ce289570eb3bd78289142752c15afc286f2

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