Implementing Caching into the Rock, Paper, Scissors Game

rock paper scissors caching ruby

After reviewing the Rock, Paper, Scissors game code, I realized that there was a bug with the computer guessing mechanism. In this guide we’re going to walk through how to implement caching in order to correct the issue.


Refactor the Rock, Paper, Scissors class by implementing caching for the computer guessing method.

Exercise File

Code File

Exercise Description

There’s currently a subtle bug with the Rock, Paper, Scissors game we built a few days ago. Work through the implementation code provided in order to see how caching can correct the issue.

Real World Usage

After reviewing the Rock, Paper, Scissors game I realized that there was an issue with the computer guessing component of the class. This is a great example of how subtle bugs can make their way in programs and, more importantly, how to fix them. Additionally, in order to correctly fix this bug you’ll need to integrate caching, which is a critical feature in a large number of applications and algorithms.


Can be found on the solutions branch on github.


Please enter your comment!
Please enter your name here