Git Product home page Git Product logo

rock-paper-scissors's Introduction

Rock, Paper, Scissors

Simple rock, paper, scissors game with a slight twist!

Unless you've been living under an actual rock, the rules of the game are simple: rock blunts scissors, scissors cuts paper and paper covers rock. You play against an opponent by simultaneously forming the shapes with your hands. The game is more than 4,000 years old!

The twist in this implementation is that a human plays against an AI. As the game is repeated the AI gets 'smarter' and takes advantage of an interesting strategy which exploits the irrationalities present in human behaviours and actions. The AI 'strategy algorithm' is based on a series of observations that took place in a study conducted in China (Xu et al., 2013).

Yes... THERE ARE studies of people actually playing rock, paper, scissors.

TL;DR: the study observed that players followed a 'win-stay, lose-shift strategy' in which:

  1. If a player wins, they are likely to play the hand their opponent played. E.g. If I win by playing rock, my next move should be scissors as I think my opponent will play paper.
  2. If a player loses, they are likely to shift their hand to what would beat what their opponent played. E.g. If I lost playing scissors, my next play should be paper as I think my opponent will keep playing rock.

For the full paper, see here.

How to play

When prompted, choose total number of games (int)

rock for rock, paper for paper, scissors for scissors. Couldn't have been easier!

When prompted, choose y to play the game or n to quit.

Have fun!

Notes

I'm having trouble printing the โœŒ emoji (which is part of the code) on my computer. Would love to know if this is also the case for others?

License

MIT

rock-paper-scissors's People

Contributors

m-alifida avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.