Skip to main content

Multi-player and multi-action Rock, Paper, Scissors game client

Project description

rock-paper-scissors-py

Multi-player and multi-action Rock, Paper, Scissors game client.

Installation

To install, run the following commands:

pip install rock-paper-scissors-py

# or

git@github.com:jwc20/rock-paper-scissors-py.git
cd rock-paper-scissors-py

To use the engine, first setup and activate a python virtual environment (venv)

python3 -m venv .venv
. ./.venv/bin/activate

Install from requirements.txt

pip3 install -r requirements.txt

Usage:

In your Python file, to import, type

import rps

Set the number of actions allowed in the game (beats logic will be generated based on the number of actions)

action_three = 3  # rock, paper, scissors

# => BEATS = {
#        0: [2],  # Rock beats Scissors
#        1: [0],  # Paper beats Rock
#        2: [1],  # Scissors beats Paper
#    }


action_five = 5      # rock, paper, scissors, Spock, lizard

# => BEATS = {
#        0: [2, 3],  # Rock crushes Scissors & Lizard
#        1: [0, 4],  # Paper covers Rock & disproves Spock
#        2: [1, 3],  # Scissors cuts Paper & decapitates Lizard
#        3: [1, 4],  # Lizard eats Paper & poisons Spock
#        4: [0, 2],  # Spock vaporizes Rock & smashes Scissors
#    }

Set the players with either fixed or random actions

player_jae = rps.FixedActionPlayer("Jae", 0) # always plays Rock, like an idiot

# bunch of random players with random actions
random_player_names = [f"random{i}" for i in range(20)]
random_players = [rps.RandomActionPlayer(name) for name in random_player_names]

Set the game and play

game = rps.Game(random_players, action_three)

game.play()

Example

Run the example.py in the root directory

python example.py

Note

Game consists of m players and n actions where m >= 2 and n >= 3 and n is an odd number.

Actions are hand gestures played by the players (rock, paper, scissors).

If the number of actions set in the game is between 5 and 15, the game uses the rules made by Sam Kass and David C. Lovelace.


See also:

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

rock_paper_scissors_py-0.1.3.1.tar.gz (5.6 kB view details)

Uploaded Source

Built Distribution

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

rock_paper_scissors_py-0.1.3.1-py3-none-any.whl (5.9 kB view details)

Uploaded Python 3

File details

Details for the file rock_paper_scissors_py-0.1.3.1.tar.gz.

File metadata

  • Download URL: rock_paper_scissors_py-0.1.3.1.tar.gz
  • Upload date:
  • Size: 5.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for rock_paper_scissors_py-0.1.3.1.tar.gz
Algorithm Hash digest
SHA256 93116f7bc6398ba17a14f1e0a6ae4b09f2b8c75af82a96988de28a02dbda8936
MD5 da1ca57deb63f89c49b8e6e1e310869f
BLAKE2b-256 58eddbed052f1e29eb65704a1d456bc00c4b7469bec8c17c2fdd0a46e05b8c4c

See more details on using hashes here.

Provenance

The following attestation bundles were made for rock_paper_scissors_py-0.1.3.1.tar.gz:

Publisher: python-publish.yml on jwc20/rock-paper-scissors-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file rock_paper_scissors_py-0.1.3.1-py3-none-any.whl.

File metadata

File hashes

Hashes for rock_paper_scissors_py-0.1.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8a6ecf8612ad9d0f1291f62bd28e6e7bd37d44ed183815f2b5307c90c3ba88bc
MD5 98d122927ae7d9610cf2e3f0fe1e4f5b
BLAKE2b-256 7c48719e30471ad9dc1a20b248a34273dbda040f7a4ad7d878fddeeab97f4f7f

See more details on using hashes here.

Provenance

The following attestation bundles were made for rock_paper_scissors_py-0.1.3.1-py3-none-any.whl:

Publisher: python-publish.yml on jwc20/rock-paper-scissors-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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