Fundamentals
Search
K

Project 1: Scissors Paper Stone (Part 2)

✂️📃💎🤩

Introduction

Part 2 assumes we have learned about global variables, and the More Comfortable section assumes we know how to use global varaibles as game modes. We'll now update our SPS Part 1 to support game states.
If you completed the Base features of SPS Part 1 but didn't finish the More Comfortable section, please complete Base for SPS Part 2 before going back to attempting More Comfortable for both parts.

Past Projects

Take a look at past projects by previous Fundamentals students to visualise how the full game can look like.

Base

Win-Loss Record

Add state to your program such that it keeps track of the number of times the user has won and the number of times the computer has won. Output this win-loss record in a format you like in the program output. You can also output the number of draws and/or each party's winning percentage if you'd like.

User Name

To make this game more personal, add a feature to collect the user's name as the first input after the page loads. We can prompt the user to enter their name first by adding to the page's HTML. Once the user submits their name, the program can return output to prompt the user to start playing Scissors Paper Stone by entering one of the 3 objects. Use the user's name to personalise win-loss record and other relevant output.

Formatting

Make the output of your game look nice. You can use the string '<br>' to create new lines in the output. Add the user name and the win/loss record. Format a message depending on how well the player is doing:
The computer chose scissors ✂️.
You chose paper 🗒.
You lose! Bummer.
So far Kai, you've been winning 5/7 turns. Pretty good!

More Comfortable

There is no need to implement all the different features sequentially in one version of your game. Feel free to choose what you find interesting and appropriately challenging and implement only that.

Reverse Game Mode

You decide to prank your friends and create an SPS game mode where the rules are reversed: scissors beat stone, stone beats paper, and paper beats scissors. Create a game mode where if a user types in "reverse", it reverses the SPS rules.

Korean Scissors Paper Stone

The following is adapted from Wikipedia:
In Korea, a two-player upgraded version exists by the name muk-jji-ppa. After showing their hands, the player with the winning throw shouts "muk-jji-ppa!" upon which both players throw again. If they throw differently (for example, rock and paper, or paper and scissors), whoever wins this second round shouts "muk-jji-ppa!" and thus the play continues until both players throw the same item (for example, rock and rock), at which point whoever was the last winner becomes the actual winner.
Update your program state such that it can keep track of the most recent winner, and update the program logic to declare the most recent winner the ultimate winner when there is a draw.

Versions

Allow the player to select if they want to play normal or Korean versions of the game.

Computer vs. Computer

Add a mode that lets the computer choose for you on each turn.

Further Variations

Implement other variations to the game as described here. The user can select which variation they would like to play.

Submit

Share your work with your Section mates for peer-learning, and with your SLs for review.
  1. 1.
    Go to gist.github.com and login with your GitHub account.
  2. 2.
    Copy code from script.js into a new gist.
    1. 1.
      Title the Gist and the file as you wish
    2. 2.
      Share your Gist on Slack!
  3. 3.
    Include the following questions, along with your answers, at the top of your gist:
/*
How many hours did you spend on this assignment?:
What part of the assignment did you spend the most time on?:
How comfortable did you feel with this assignment? (1-5):
Is there anything in this code that you feel pleased about?:
What's one aspect of your code you would like specific, elaborate feedback on?:
*/
GitHub gist
Share the link to your gist with your Section in Slack!

Reference Solution

The reference solution implements the Base functionality for both SPS Parts 1 and 2. Please only refer to the reference solution after you have attempted the project. Note that there are many ways to implement the project and the reference solution is only 1 way.
View the reference solution for SPS-Part2 (up till More Comfortable).