lewdev / rock-paper-scissors-battle

Watch a simulation of emoji Rock, Paper, Scissors battle it out.

Home Page:https://lewdev.github.io/apps/rock-paper-scissors-battle/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

rock-paper-scissors-battle

Watch a simulation of emoji Rock, Paper, Scissors and multiple variants battle it out:

  • πŸ§±πŸ“„βœ‚οΈ Rock, Paper, Scissors
  • πŸ¦ŽπŸ–– Lizard-Spock Expansion
  • πŸ”₯πŸŒ³πŸ’§ Fire, Tree, Water
  • 🌎 Elements
  • πŸ’‘ Boys Chase Girls

Demo

See demo

Description

This simulates Rock, Paper, and Scissors initially placed randomly around the screen and then chasing after their nearest prey. It's interesting to see the outcomes being completely random.

Click on the drop down to watch the other variants play out. Modify the source code to add your own variations.

To add your own, add a name and ruleset to the ruleSets array.

New Features

  • βœ– Multiple variations of the game.
  • πŸ’₯ Event feed.
  • πŸ’¨ When an object has no targets, it flees.
  • 🦘 Objects bob as they move.
  • πŸ™Œ Just like in the show, the game announces "Hail Sam Kass" before the battle begins.
  • ✏ You can enter your own custom rules if you run the source code yourself (instructions below).

Standard RPS Rules

βœ‚οΈ cuts πŸ“„ covers πŸ’Ž crushes βœ‚οΈ

Lizard-Spock Expansion Rules

βœ‚οΈ cuts πŸ“„ covers πŸ’Ž crushes 🦎 poisons πŸ–– smashes βœ‚οΈ decapitates 🦎 eats πŸ“„ disproves πŸ–– vaporizes πŸ’Ž crushes βœ‚οΈ

Run this code

Install 3 basic global apps: serve, concurrently, and opener. It basically starts a server on the src directory and views it in your default browser.

npm i

Start the server and open it in your default browser.

npm start

Inspiration

This was an attempt to create something for the JS1024 (2021). I started on this just after the deadline so I wasn't planning on submitting it but rather just see if I could create something for it.

Turns out, it's very hard to do and getting even a small app down to 1024 bytes seems impossible.

The Lizard-Spock Expansion

Inspired by the code.golf hole "Rock-paper-scissors-Spock-lizard" (code challenge), I decided to create a version of this with the addition of πŸ––Spock and 🦎Lizard. I looked it up and found that became popularized by The Big Bang Theory in a scene when Sheldon and Raj can't agree about what to watch on TV.

Additional Research

There is an interesting website, umop.com, with many variatians of the game and additional objects. The website includes RPS-7, 9, 11, 15, 25, and even 101! I implemented RPS-7, but I don't know if I'll get around to doing the others.

I made up the "5 Elements" variation. Please send me your variations if you have any!

Compression Strategy

  1. JSCompression
  2. Google Closure
  3. A JavaScript Compressor
  4. JavaScript Minifier

About

Watch a simulation of emoji Rock, Paper, Scissors battle it out.

https://lewdev.github.io/apps/rock-paper-scissors-battle/

License:MIT License


Languages

Language:JavaScript 68.3%Language:HTML 31.7%