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

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.4.tar.gz (44.1 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.4-py3-none-any.whl (29.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: blackrhinorandomminigame-0.1.4.tar.gz
  • Upload date:
  • Size: 44.1 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.4.tar.gz
Algorithm Hash digest
SHA256 805c1a378ececd4d06b9378242b1520174966238fd6b47bcb6bcb08e843bc391
MD5 a8a036544e578d2bfe67ef4fcf0ab349
BLAKE2b-256 83f43aeaec63a35718c38f680967078f6ba4f2baefd6643e49d1d81ebe42a697

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for blackrhinorandomminigame-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 1de6a28374118d5ace7f05119e5bb8e16eb58cfb459e1ca0d003b15a6d41d6a3
MD5 ef1f32e5117d88031a9a72f3b277fe23
BLAKE2b-256 18192e27388e9f8136ec81411d9fe34ff0f1dbfff3a5ef7ca123a37b11fb0a4b

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