Skip to content

lucymcphail/rock-paper-scissors

Repository files navigation

rock-paper-scissors

A rock, paper, scissors game using an “intelligent” algorithm.

Installation and Usage

Firstly, make sure you have leiningen installed on your system. Leiningen is a build tool for Clojure, and is neccesary to run or compile the program. Once leiningen is installed, you can run the game with:

$ lein run

Alternatively, if you want to run the program on a computer without leiningen, you can generate a Java file using:

$ lein uberjar

The .jar file can be found in /target/uberjar/, copied onto another computer and run with the following command:

$ java -jar path/to/file/rock-paper-scissors-0.1.0-standalone.jar

Theory

This game works using two algorithms. The first exploits human psycology, the second uses basic machine learning principles.

The first algorithm is based on simple logic: if you win, you will want to play the same item again; if you lose, you will avoid it. Based on this, if you lose, you should play what didn’t come up and if you win, you should play what your opponent just played. This Numberphile episode with fellow redhead Hannah Fry describes this in more detail:

Winning at Rock Paper Scissors - Numberphile

The problem with this is it’s perfectly predictable, when someone works out what’s going on. So, the second algorithm has a 25% chance of being used. Every time the player makes a choice, the item that would beat the player’s choice becomes more heavily weighted. The more weighted an item is, the more likely it is to be chosen whenever the second algorithm is used.

Combined, these two algorithms create an overall fairly intelligent AI that will probably beat a human who does not know how to exploit it.

License

rock-paper-scissors is licensed under the MIT license

About

Terminal based rock, paper, scissors game

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published