If you cheat on rock-paper-scissors, you should look within: a minimal approach

Here is the game: http://www.luck.consulting
Here is the code: https://github.com/plumSemPy/rock-paper-scissors

There comes a time in everyone’s life, where tough decisions should be made — who gets the last slice? who takes off the shirt first?

In impasses like this, instead of spiraling down a futile vortex of reasoning to turn the tides in my favor, I prefer the more just and quick solution of luck. Toss a coin, roll a dice, or play a game of rock paper scissors (best of three of course).

I like rock-paper-scissors better because it gives one the feeling of control and people are less likely to debate the outcome. I searched around (like two links tops), and there are no asynchronous ways to play. What that means is that you always need to have you and your opponent ready, and then you send them a link and you guys play at the same time. There is a server involved and all that drama.

I thought, well, most times I am busy doing stuff and I have asynchronous conversations going on (asynchronous is like when you send a text message. The receiver can answer anytime, it is not like a phone call, which is synchronous, and they need to talk back almost immediately when they talk to you). So I want an asynchronous way to play it.

What I used to do was to write a sequence of 3, encrypt it, and send it to a friend with the secret. That way they could not cheat by accident. I should emphasize here that the game is played on good faith. If you cheat on rock-paper-scissors, you should look within. If I just sent the plain text, they can’t help seeing my hand. Same if I base64 encode it, it is too short and they will pattern match after a while. AES encryption is long enough that ain’t nobody got time for that.

So I just did that on a single HTML, CSS, vanilla JS page. You play your hand, send the state to a friend, they paste that URL and play their hand, and they will know who won.

I did this as I was waiting for Mortal Kombat 11 to finish downloading, which is awesome by the way (and added some more bells and whistles later). Am I flexing? I don’t know; is this impressive or depressive for circa an hour of work? Let me know in the comments and don’t forget to like and subscribe (jk).

One piece of advice, don’t use Heroku with Google domains ugh. The former does not give you an IP for an A record and the latter does nothing to allow for a root CNAME record. Unlike Cloudfl💘re. If Google allowed for only forwarding of root to www, then that would work too! but no it forwards root and www to something else, and you cannot forward www to itself.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: