Fri 26 September 2025

Rock Paper Scissors Arena Simulation

Posted by Al Sweigart in misc   

As part of an AI-generated code experiment, I had ChatGPT 5 create a Rock Paper Scissors "arena simulator" where different emojis play a game of tag. Emoji converts the "prey" emoji that they catch. This idea follows the tradition of "spatial rock paper scissors" simulations, such as this Julia-language "agents" framework example. I did multiple attempts, but you can view one chat log here.. You can download the rpsarena package from PyPI and see the source code in its git repo. The rpsarena package uses tkinter and has no dependencies outside of the Python standard library. After installing, run python -m rpsarena --help to view instructions on how to set up a game.

Running the Simulation

Install with pip from PyPI: pip install rpsarena

Run the "screensaver" mode (which automatically restarts new games in an 800x800 window) from the terminal: python -m rpsarena

The --help command line option displays the following:

usage: __main__.py [-h] [-s WIDTH HEIGHT] [-u UNITS] [-d DELAY] [--seed SEED] [-n NUM_GAMES] [--no-ff] [--bg BG]
                   [--countdown COUNTDOWN] [--windowless] [-q] [--showstats] [--blocks BLOCKS] [--no-log]
                   [--logfile LOGFILE]
RPS Arena
options:
  -h, --help            show this help message and exit
  -s, --size WIDTH HEIGHT
                        Window size as WIDTH HEIGHT (default 800 800)
  -u, --units UNITS     Number of units per emoji kind (default 50)
  -d, --delay DELAY     Tick delay in ms (0 coerced to 1) (default 30)
  --seed SEED           Random seed for first game; subsequent games use seed+1, seed+2, ...
  -n, --num-games NUM_GAMES
                        Number of games to play (0=unlimited). Closes after last game.
  --no-ff               Disable Fast Forward (no auto-switch to delay=1)
  --bg BG               Background color or image filename (windowed). Colors: name or #RRGGBB.
  --countdown COUNTDOWN
                        Seconds to pause after placement (windowed only).
  --windowless          Run without Tk window. If -n not set, defaults to 1.
  -q, --quiet           Suppress stdout log messages (file logging unaffected unless --no-log).
  --showstats           Show elapsed time, step, and counts in lower-right corner (windowed only).
  --blocks BLOCKS       Number of random blocks (e.g., '5') OR path to JSON file describing blocks.
  --no-log              Disable logging to file (stdout still used unless --quiet).
  --logfile LOGFILE     Log file name (default rps_arena_log.txt)

I've created sensible defaults: the window is 800 x 800 and has 50 of each kind of emoji, and the game automatically restarts when one emoji wins. You can use this setup as a sort of screensaver or fish tank; something interesting to look at. Each time an emoji is consumed, it outputs a log of simulation step followed by a count of each emoji.

You can also run the simulation in a windowless mode if you just want to get the final results as fast as possible for several games. The simulation is deterministic, so you can set the random seed value to replay games.

The emoji tend to literally corner their prey in the corners of the window. You can also add a "blocks" json file to put barriers in the arena space for more interesting layouts. The emoji head straight for the nearest prey and don't do any pathfinding, so blocks could create games where no emoji ever wins.

Vibe Coding Thoughts

This was one of my earliest attempts at "vibe coding", and while it took several attempts, here are some surprising aspects I encountered in the process:

  • As usual, the LLM gave me about 80% of what I wanted off the bat with the first detailed prompt I gave it. I wasn't familiar with the term agent-based modeling, though I found that out later from Googling for similar simulations to the one I made.
  • The separate speeds for attraction to prey and repulsion from predator on top of a base speed was a nice feature that I wouldn't have thought of. This is common in other simulations I've found on the web. There is also an ALLY_REPEL setting that keeps agents of the same type from clumping together, which I wouldn't have initially tried.
  • Most of the features are suggestions that came from me: logging, seed setting, countdown, blocks, and the "fast forward" feature to speed up the game when the outcome is certain. However, the LLM was able to create these at my prompting.
  • Some of the text for the --help text isn't what I would use. I've modified it slightly.
  • The final result had about 1,000 lines of code. Overall, I probably saved time because I wasn't quite familiar with tkinter.
  • I'd be interested to see non-programmers look at this program and then try to recreate it themselves with various LLMs, given only the guidance that the language is Python and the GUI framework is tkinter.

This experience reinforces my conceptions: AI-assisted programming is a productivity boost for expert software developers creating conventional software that is small in scale, particularly with unfamiliar frameworks/libraries/languages the developer would spend a lot of time reading documentation for. RPS Arena was an ideal I had based on a video clip I saw on social media of a similar app, but I never really had time to implement it. AI-assisted coding didn't save as much time as I liked (and there still remains work I'd like to do on this project), but it was a way to help me wrap up this small-scoped side quest project.

Unlike the previous vibe coding experiment failures, I consider this a success even though there are still minor refactorings I want to make the source.


Check out other books by Al Sweigart, free online or available for purchase:

...and other books as well! Or register for the online video course. You can also donate to or support the author directly.