Coder Social home page Coder Social logo

alexmaderap / generalized-rock-paper-scissors Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 6 KB

This project implements a generalized rock-paper-scissors game that supports an arbitrary odd number of non-repeating moves. The game can be run from the command line with specified moves, and it determines the winner based on the order of the moves provided.

JavaScript 100.00%

generalized-rock-paper-scissors's Introduction

Generalized Rock-Paper-Scissors Game

This project implements a generalized rock-paper-scissors game that supports an arbitrary odd number of non-repeating moves. The game can be run from the command line with specified moves, and it determines the winner based on the order of the moves provided.

Features

  • Supports any odd number (โ‰ฅ 3) of non-repeating moves.
  • Accepts moves as command line arguments.
  • Provides error messages for incorrect arguments.
  • Determines victory based on the order of moves.

Installation

  1. Clone the repository
  2. Install dependencies:
npm install

Usage

To run the game, use the following command format:

node game.js move1 move2 move3 ...

For a standard Rock-Paper-Scissors game:

node game.js rock paper scissors

For an extended Rock-Paper-Scissors-Lizard-Spock game:

node game.js rock paper scissors lizard spock

Error Handling

If the arguments are incorrect, the program will display an error message indicating what is wrong and provide an example of correct usage. Examples of incorrect arguments include:

  • Providing an even number of moves.
  • Providing fewer than 3 moves.
  • Providing repeating moves.

Rules

The victory is defined as follows:

  • Half of the next moves in the circle win.
  • Half of the previous moves in the circle lose.

generalized-rock-paper-scissors's People

Contributors

alexmaderap 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.