rpsarena


Namerpsarena JSON
Version 0.1.0 PyPI version JSON
download
home_pageNone
SummaryA simulation of Rock Paper Scissors units chasing each other in a GUI window. Highly configurable.
upload_time2025-08-23 22:43:48
maintainerNone
docs_urlNone
authorAl Sweigart
requires_python>=3.2
licenseNone
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # RPS Arena

A simulation of Rock Paper Scissors units chasing each other in a GUI window. Highly configurable.

Units roam a white arena using a **closest-choice** strategy:
- Each unit **chases** the nearest unit it can defeat, **or** **flees** the nearest unit that can defeat it — whichever is closer.
- On contact, the loser converts to the winner’s kind.
- When only one kind remains, the game ends; either exits (if a seed was specified) or restarts with a fresh random seed.

## Features
- **Fast Forward:** When only two kinds remain and one beats the other (eventual victory), delay auto-switches to **1 ms** to speed up the finish. Enabled by default; disable with `--noff`.
- **Fixed-size window:** no user resizing (preventing accidental scale changes).
- **Deterministic runs:** `--seed` fixes the RNG seed (plays a single game and exits).
- **Live logging:** `rps_arena_log.txt` records settings, a header row, conversion snapshots, and an end-of-game summary including **elapsed time** and **total step count**.

## Requirements
- Python **3.2+**
- Standard library only (tkinter included with most Python installs)

## Usage

```bash
python rps_arena.py -s 1200 800 -u 240 -d 16
python rps_arena.py --seed 12345 -d 0      # delay 0 is coerced to 1 ms
python rps_arena.py --noff                 # disable Fast Forward
````

### Command-line Options

* `-s, --size WIDTH HEIGHT` – window size (default `1000 700`)
* `-u, --units N` – total units (default `150`)
* `-d, --delay MS` – per-tick delay in milliseconds; **0 → coerced to 1** (default `30`)
* `--seed SEED` – run exactly one deterministic game with the given seed
* `--noff` – disable Fast Forward auto-speed-up

## Log File Format (`rps_arena_log.txt`)

1. **Line 1:** Start timestamp and settings (size, units, delay, seed, kinds, fast\_forward on/off)
2. **Line 2:** CSV header – `step,<emoji1>,<emoji2>,<emoji3>`
3. **Subsequent lines:** `step,count1,count2,count3` – appended **only when a conversion happens**
4. **Final line:** `game_end at <timestamp>; elapsed=<seconds>s; steps=<N>`

Example snippet:

```
start=2025-08-23 12:34:56 | size=1000x700 | units=150 | delay_ms=30 | seed=987654 | kinds=paper,rock,scissors | fast_forward=on
step,📄,🪨,✂️
42,60,55,35
57,65,50,35
game_end at 2025-08-23 12:35:49; elapsed=53.123s; steps=172
```

## Customization

You can pass your own dictionaries into the constructor (if integrating into another program):

```python
custom_emoji = {"rock": u"🪨", "paper": u"📄", "scissors": u"✂️"}
custom_beats  = {"rock": "scissors", "paper": "rock", "scissors": "paper"}
custom_loses  = {"rock": "paper",    "paper": "scissors", "scissors": "rock"}

RPSArena(root, width, height, units, delay_ms,
         emoji=custom_emoji, beats=custom_beats, loses_to=custom_loses)
```

> This build uses **single-prey/single-predator** rules per kind. If you’d like multi-prey or multi-predator rules (e.g., a kind beats multiple others), ask and we’ll provide a drop-in patch.

## License

MIT

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "rpsarena",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.2",
    "maintainer_email": null,
    "keywords": null,
    "author": "Al Sweigart",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/92/fe/2713ee1225df2402f0afcee43dc78decfcff711fe04bb0af66943b7d1674/rpsarena-0.1.0.tar.gz",
    "platform": null,
    "description": "# RPS Arena\n\nA simulation of Rock Paper Scissors units chasing each other in a GUI window. Highly configurable.\n\nUnits roam a white arena using a **closest-choice** strategy:\n- Each unit **chases** the nearest unit it can defeat, **or** **flees** the nearest unit that can defeat it \u2014 whichever is closer.\n- On contact, the loser converts to the winner\u2019s kind.\n- When only one kind remains, the game ends; either exits (if a seed was specified) or restarts with a fresh random seed.\n\n## Features\n- **Fast Forward:** When only two kinds remain and one beats the other (eventual victory), delay auto-switches to **1 ms** to speed up the finish. Enabled by default; disable with `--noff`.\n- **Fixed-size window:** no user resizing (preventing accidental scale changes).\n- **Deterministic runs:** `--seed` fixes the RNG seed (plays a single game and exits).\n- **Live logging:** `rps_arena_log.txt` records settings, a header row, conversion snapshots, and an end-of-game summary including **elapsed time** and **total step count**.\n\n## Requirements\n- Python **3.2+**\n- Standard library only (tkinter included with most Python installs)\n\n## Usage\n\n```bash\npython rps_arena.py -s 1200 800 -u 240 -d 16\npython rps_arena.py --seed 12345 -d 0      # delay 0 is coerced to 1 ms\npython rps_arena.py --noff                 # disable Fast Forward\n````\n\n### Command-line Options\n\n* `-s, --size WIDTH HEIGHT` \u2013 window size (default `1000 700`)\n* `-u, --units N` \u2013 total units (default `150`)\n* `-d, --delay MS` \u2013 per-tick delay in milliseconds; **0 \u2192 coerced to 1** (default `30`)\n* `--seed SEED` \u2013 run exactly one deterministic game with the given seed\n* `--noff` \u2013 disable Fast Forward auto-speed-up\n\n## Log File Format (`rps_arena_log.txt`)\n\n1. **Line 1:** Start timestamp and settings (size, units, delay, seed, kinds, fast\\_forward on/off)\n2. **Line 2:** CSV header \u2013 `step,<emoji1>,<emoji2>,<emoji3>`\n3. **Subsequent lines:** `step,count1,count2,count3` \u2013 appended **only when a conversion happens**\n4. **Final line:** `game_end at <timestamp>; elapsed=<seconds>s; steps=<N>`\n\nExample snippet:\n\n```\nstart=2025-08-23 12:34:56 | size=1000x700 | units=150 | delay_ms=30 | seed=987654 | kinds=paper,rock,scissors | fast_forward=on\nstep,\ud83d\udcc4,\ud83e\udea8,\u2702\ufe0f\n42,60,55,35\n57,65,50,35\ngame_end at 2025-08-23 12:35:49; elapsed=53.123s; steps=172\n```\n\n## Customization\n\nYou can pass your own dictionaries into the constructor (if integrating into another program):\n\n```python\ncustom_emoji = {\"rock\": u\"\ud83e\udea8\", \"paper\": u\"\ud83d\udcc4\", \"scissors\": u\"\u2702\ufe0f\"}\ncustom_beats  = {\"rock\": \"scissors\", \"paper\": \"rock\", \"scissors\": \"paper\"}\ncustom_loses  = {\"rock\": \"paper\",    \"paper\": \"scissors\", \"scissors\": \"rock\"}\n\nRPSArena(root, width, height, units, delay_ms,\n         emoji=custom_emoji, beats=custom_beats, loses_to=custom_loses)\n```\n\n> This build uses **single-prey/single-predator** rules per kind. If you\u2019d like multi-prey or multi-predator rules (e.g., a kind beats multiple others), ask and we\u2019ll provide a drop-in patch.\n\n## License\n\nMIT\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "A simulation of Rock Paper Scissors units chasing each other in a GUI window. Highly configurable.",
    "version": "0.1.0",
    "project_urls": null,
    "split_keywords": [],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "758aba70b5b1bcba90ea3d996bfccecb9eb32f15b848db77f7a7b63d004cb287",
                "md5": "849673853c9da07f51a8f2867f49b8c5",
                "sha256": "ba7aaba20c7968f9d5381c66dc94e46f11e4b2f289c6036d216088cd10f094e6"
            },
            "downloads": -1,
            "filename": "rpsarena-0.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "849673853c9da07f51a8f2867f49b8c5",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.2",
            "size": 7923,
            "upload_time": "2025-08-23T22:43:47",
            "upload_time_iso_8601": "2025-08-23T22:43:47.195827Z",
            "url": "https://files.pythonhosted.org/packages/75/8a/ba70b5b1bcba90ea3d996bfccecb9eb32f15b848db77f7a7b63d004cb287/rpsarena-0.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "92fe2713ee1225df2402f0afcee43dc78decfcff711fe04bb0af66943b7d1674",
                "md5": "13abee9fbe5a4357b377a9cdef23a6cc",
                "sha256": "f997abf2ac73dbb9d31dabc0ecb2b0cb5116b63cda50b1c2e4848b90d76defc0"
            },
            "downloads": -1,
            "filename": "rpsarena-0.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "13abee9fbe5a4357b377a9cdef23a6cc",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.2",
            "size": 7456,
            "upload_time": "2025-08-23T22:43:48",
            "upload_time_iso_8601": "2025-08-23T22:43:48.476197Z",
            "url": "https://files.pythonhosted.org/packages/92/fe/2713ee1225df2402f0afcee43dc78decfcff711fe04bb0af66943b7d1674/rpsarena-0.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-08-23 22:43:48",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "rpsarena"
}
        
Elapsed time: 3.41041s