r/Python 1d ago

Showcase A Modular Framework for Custom Rock-Paper-Scissors games

I'd like to share the first Python project that I’ve taken from an initial idea all the way through to publishing on GitHub and PyPi. It's a modular framework for creating Rock-Paper-Scissors games and variants.

What My Project Does:

It is both a playable "Rock Scissors Paper" CLI game, and a flexible framework for building custom versions of the classic game. It's designed to:

  • Support additional choices (e.g., Rock, Paper, Scissors, Lizard, Batman).
  • Ensure consistent win-loss relationships based on the number of choices.
  • Be easily extended for more complex variants.

Target Audience:

This project was primarily written for my own learning experience, though it may be useful for hobbyists to use as the basis of more complex Rock Scissor Paper games.

Features:

  • Customizable Rules: Easily modify the choices and define which hands win.
  • Extensible: Add as many options as you want (as long as they meet the rules).
  • Simple Interface: Play a simple terminal-based game against the computer, or replace the UI class with a more complex interface.
  • Unit tests: Game logic supported by pytests.
  • Single Python file: Can easily be split into multiple modules for more complex versions.

First Release:

GitHub: https://github.com/JamzTyson/Rock_Scissors_Paper

PyPi: https://pypi.org/project/rock-scissors-paper-framework/

I'd love to hear your feedback on this project.

3 Upvotes

9 comments sorted by

1

u/yrubooingmeimryte 1d ago

Why?

1

u/JamzTyson 1d ago edited 1d ago

u/yrubooingmeimryte asked why I wrote this:

  1. Becaue 99% of the implementations of "Rock Scissors Paper" found on the Internet are spaghetti code, with very little structure, no tests, little or no documentation, and not easily extendable due to the absense of modularity. Typical implementations go against everything I've read about SOLID design, OOP, DRY, modularity and testability.

  2. Because I can only get so far from reading and practicing on my own, so I wanted to create a relatively simple project in which I could try to structure a project following best practices and get feedback from real people like yourself.

  3. Because the Python packaging ecosystem has a reputation for being horribly complicated, with dozens of different tools for dependency management and packaging. I wanted to work through the entire process, end to end, using PyCharm, Poetry, GitHub, pytest and PyPi.

  4. Because every developer has a first project, and this is mine.

  5. Because I wasn't expecting to be downvoted for showcasing my work. I expected the r/Python community to be a little more encouraging and constructive.

1

u/yrubooingmeimryte 1d ago

Don’t you think you should reimplement this using torch so you can get the benefits of gpu parallelization?

3

u/JamzTyson 1d ago

No I don't.

-1

u/yrubooingmeimryte 1d ago

What if I need to run many parallel instances of rock papers scissors on my GPU?

1

u/JamzTyson 1d ago

Then you can instantiate multiple instances of the framework and run them in parallel.

What if you want to run it as a GUI game? Then you can replace the UI class with your GUI code.

What if you want to run the game as a two player game? Then you can replace the robo_choice() function with a second use of the player_choice() function.

What if you want to the user to enter number choices rather than initial letters? Then you can modify GameOption._choice_keys.

What if you want the computer to use statistical analysis to determine its next move rather than a purely random choice? Then you can implement a more advance robo_choice() function.

-4

u/yrubooingmeimryte 1d ago

No, you would need to convert them to tensors to parallelize these on the GPU.

3

u/JamzTyson 1d ago

No, you would need to convert them to tensors

What do you mean by "them"?

-4

u/yrubooingmeimryte 1d ago

If you don’t know then you’re not ready to write python.