Code Monkey home page Code Monkey logo

rockpaperscissor's Introduction

Rock Paper Scissors in Scala

A 'vanilla' Scala implementation using OO and FP concepts.

OO: Used for dependency management.

FP: Same input results in same output, also higher-order functions. Side-effects, notably the console, are abstracted but not managed using as effects.

Worthwhile in this implementation

  • The tests:
    • RockPaperScissorsCliSuite was written from a behavior perspective simulating 'end to end' interaction with the console. A goal here is to have a test that is relatively stable when the implementation would change.

Note, not implemented:

  • Advanced computer logarithm. The current one just implements generates a random 'hand'.
    • For more advanced logic the previous outcomes and 'hands' can be passed.
      • The function () => Option[Hand] would turn into something like List[Outcome] => Option[Hand], where Outcome also contains the moves played by both players.

Running and development

This implementation uses scala-cli. A nix flake is setup to setup the required environment.

Run:

scala-cli run .

Test (watching file changes):

scala-cli test -w .

IDE:

Running either of above commands generates project file for IntelliJ IDEA (bsp) and Metals (e.g. in VSCode).

rockpaperscissor's People

Contributors

lhohan avatar

Watchers

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