From GIS CS4
Jump to: navigation, search

Project: Rock-Paper-Scissors Part 4

Rock Paper Scissors Lizard Spock

See: https://en.wikipedia.org/wiki/Rock-paper-scissors-lizard-Spock

Rock-paper-scissors-lizard-Spock is an expansion of the classic selection method game rock-paper-scissors. It operates on the same basic principle, but includes two additional weapons: the lizard (formed by the hand as a sock-puppet-like mouth) and Spock (formed by the Star Trek Vulcan salute). This reduces the chances of a round ending in a tie (from 1/3 to 1/5). The game was invented by Sam Kass with Karen Bryla, as "Rock Paper Scissors Spock Lizard".

The game was mentioned in four episodes of The Big Bang Theory. According to an interview with Kass, the series producers did not ask for permission to use the game, but he was later referenced in an episode in the fifth season for which he thanked them on his website.

The rules of rock-paper-scissors-lizard-Spock are:

   * Scissors cut paper
   * Paper covers rock
   * Rock crushes lizard
   * Lizard poisons Spock
   * Spock smashes scissors
   * Scissors decapitate lizard
   * Lizard eats paper
   * Paper disproves Spock
   * Spock vaporizes rock
   * Rock blunts scissors

There are ten possible pairings of the five gestures; each gesture beats two of the other gestures and is beaten by the remaining two. As with the original rock-paper-scissors game, if two players pick the same gesture, it is a tie. The original rules (rock beats scissors, scissors beats paper, paper beats rock) remain the same.

Rock Paper Scissors Lizard Spock

We are going to adapt our game to include Lizard and Spock.

You will find that this is a relatively easy task due to our object oriented design.

Have fun!

Lizard and Spock Tools Constants

Include images for Lizard and Spock below the existing Rock, Paper and Scissors images:

var LIZARD_IMAGE    = getImage("avatars/piceratops-ultimate");
var SPOCK_IMAGE     = getImage("space/rocketship");

Include additional Tools constants:

var TOOL4_ID = 4;
var TOOL5_ID = 5;
var NUM_TOOLS = 5;

Initialise Lizard and Spock Tool ids:


Lizard and Spock Relationships

Modify the Relationships Class

var Relationship = function()
    this.data = [
      // relationships for Rock
      [{result: YOU_TIE, msg: ""},
       {result: YOU_LOSE, msg: "Rock is wrapped by Paper!"},
       {result: YOU_WIN, msg: "Rock blunts Scissors!"},
       {result: YOU_WIN, msg: "Rock crushes Lizard!"},
       {result: YOU_LOSE, msg: "Rock is vapourised by Spock!"}

      // relationships for Paper
      [{result: YOU_WIN, msg: "Paper wraps Rock!"},
       {result: YOU_TIE, msg: ""},
       {result: YOU_LOSE, msg: "Paper is cut by Scissors!"},
       {result: YOU_LOSE, msg: "Paper is eaten by Lizard!"},
       {result: YOU_WIN, msg: "Paper disproves Spock!"}

      // relationships for Scissors
      [{result: YOU_LOSE, msg: "Scissors are blunted by Rock!"},
       {result: YOU_WIN, msg: "Scissors cut Paper!!"},
       {result: YOU_TIE, msg: ""},
       {result: YOU_WIN, msg: "Scissors decapitate Lizard!"},
       {result: YOU_LOSE, msg: "Scissors are smashed by Spock!"}

      // relationships for Lizard
      [{result: YOU_LOSE, msg: "Lizard is crushed by Rock!"},
       {result: YOU_WIN, msg: "Lizard eats Paper!"},
       {result: YOU_LOSE, msg: "Lizard is decapitated by Scissors!"},
       {result: YOU_TIE, msg: ""},
       {result: YOU_WIN, msg: "Lizard poisons Spock!"}

      // relationships for Spock
      [{result: YOU_WIN, msg: "Spock vapourises Rock!"},
       {result: YOU_LOSE, msg: "Spock is disproved by Paper!"},
       {result: YOU_WIN, msg: "Spock smashes Scissors!"},
       {result: YOU_LOSE, msg: "Spock is poisoned by Lizard!"},
       {result: YOU_TIE, msg: ""}

Lizard and Spock Tools Classes

Add classes for Lizard and Spock after the Tools classes for Rock, Paper and Scissors:

//Lizard Object/////////////
var Lizard = function() {
    Tool.call(this, LIZARD_TOOL_ID, "Lizard", LIZARD_IMAGE);

    // additional scaling and offset of images required for KA images
    if (bIsKhanAcademy)
		this.width = 80;
		this.height = 80;
		this.xOffset = -39;
		this.yOffset = -42;

Lizard.prototype = Object.create(Tool.prototype);

//Spock Object/////////////
var Spock = function() {
    Tool.call(this, SPOCK_TOOL_ID, "Spock", SPOCK_IMAGE);

    // additional scaling and offset of images required for KA images
    if (bIsKhanAcademy)
		this.width = 80;
		this.height = 140;
		this.xOffset = -40;
		this.yOffset = -80;

Spock.prototype = Object.create(Tool.prototype);

Lizard and Spock Tools Positions

In the Board class constructor, adjust the positions for Rock, Paper and Scissors and include positions for Lizard and Spock Tools:

    // *** Specify position of tools here...
    // For 3 tool game  y: CANVAS_HEIGHT - TOOL_HEIGHT*3/4 - 10
    this.toolPos = [
    {x: 60,                     y: CANVAS_HEIGHT - TOOL_HEIGHT*3/2 - 10},   // rock
    {x: CANVAS_WIDTH/2,         y: CANVAS_HEIGHT - TOOL_HEIGHT*3/2 - 10},   // paper
    {x: CANVAS_WIDTH - 60,      y: CANVAS_HEIGHT - TOOL_HEIGHT*3/2 - 10},   // scissors
    {x: CANVAS_WIDTH/4 + 30,    y: CANVAS_HEIGHT - TOOL_HEIGHT/2 - 10},     // lizard
    {x: CANVAS_WIDTH*3/4 - 30,  y: CANVAS_HEIGHT - TOOL_HEIGHT/2 - 10}      // spock

Lizard and Spock Tools

In the Board class constructor, add Lizard and Spock Tools:

    this.addTool(new Lizard());
    this.addTool(new Spock());

Welcome Message

Adjust the welcome message:

    text("   Rock-Paper-Scissors-Lizard-Spock", 25, PLAYAREA_Y + 40 + TEXT_SIZE);

That's all there is to it - play the game!