Coder Social home page Coder Social logo

koper-game's Introduction

koper-game

Project description

This is part of the Koper hiring process. The task is to develop a rock, paper, scissors, lizard, spock game. Here is an explanation of the game by Sheldon (The Big Bang Theory), video.

The naive solution for this type of game would be to do a bunch of if/else statements to check who won. But there is a cleaner way to do this, that is using a matrix where each line indicates what the human chose and the columns what the computer chose. If the human wins, the cell value will be 1, 0 if its a tie, and 2 if the human lose. In this case, suppose that in a play the human chose "scissors", indicated by line 0, and the computer "rock", indicated by column 2, then the matrix[0][2] = 2.

There could be a small improvement in the space complexity though, as we don't need the whole matrix to know all the results. We only need to know all the ways the human can win (10 alternatives). With that, we can deduce the defeats because they are the inverse of the wins, and the ties are whenever both, human and computer, do the same choice. But, for simplicity, I decided to just use the whole matrix.

Technology stack

To complete this project it was used Typescript, React and NextJS. The unit tests were done using the package React Testing Library.

Run the project locally

To run this project on your own machine, you first need to clone the repo.

git clone [email protected]:clarammdantas/koper-game.git

Then, inside the root directory of the project, run the NextJS app.

npm run dev

# or

yarn dev

Running tests

Inside the root directory, or below it, run:

npm test

# or

yarn test

Access the project on the internet

This project was also deployed in Heroku and can be accessed through this URL https://sleepy-citadel-55985.herokuapp.com/

koper-game's People

Contributors

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